Solved

reading uploaded excel blob

Posted on 2007-12-06
7
2,157 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
  • 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
Technology Partners: 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

Technology Partners: 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!

Question has a verified solution.

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

Suggested Solutions

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
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 will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

762 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