Solved

reading uploaded excel blob

Posted on 2007-12-06
7
2,167 Views
Last Modified: 2010-04-21
i have an excel file uploaded in oracle DB as BLOB.

I want to read that excel file.

In order to that . i first wrote a method which returns a byte[] of the uploaded BLOB file


public byte[]  getFile(String rowid)  // this  returns the uploaded excel file in byte array.


Now how do i use this byte[] to read the content of the excel file ?


My excel file is like this..

http://docs.google.com/Doc?id=dcbk3w7_3mprg2v

I want to read its content.
note there is a gap between  year and description.

how do i solve ?



0
Comment
Question by:cofactor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 20419110
Make it the argument to the construciton of a ByteArrayInputStream and then read that stream with an Excel API
0
 

Author Comment

by:cofactor
ID: 20419139
thanks for the comment.

can you please provide me a link of a standard code  which reads  excel file using POI .
i used POI earlier....unfortunately i lost the standard code.

see, i have integer cell as well as String cells in the content....so cell checking and reading is also important.

My another concern is , there is big gap between year and description.


However, i would appreciate , if you please forward me a link which shows how to read using POI.
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 20419231

InputStream myxls = new ByteArrayInputStream(blobBytes);
HSSFWorkbook wb     = new HSSFWorkbook(myxls);

Open in new window

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 92

Expert Comment

by:objects
ID: 20424029
don't convert your blob to a byte array (its unecessary and inefficient), just return the blob stream directly

public InputStream  getFile(String rowid)  // this  returns the excel stream.

you can then use:

HSSFWorkbook wb     = new HSSFWorkbook(getFileStream(rowid));
0
 
LVL 92

Expert Comment

by:objects
ID: 20424038
or using the blob directly:

HSSFWorkbook wb     = new HSSFWorkbook(blob.getBinaryStream());
0
 

Author Closing Comment

by:cofactor
ID: 31413126
excellent
0
 

Author Comment

by:cofactor
ID: 20458782
Thanks CHEJ ,i was looking for that exactly.

Thanks Object, that was also a good solution .but i  have been provided the byte[]  array in fact.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
collection output issue 9 92
ArrayList Adding/settign data 3 37
Setup Eclipse for Andriod development 2 19
Selenium WebElement Login button findElement 9 20
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question