Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2306
  • Last Modified:

reading uploaded excel blob

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
cofactor
Asked:
cofactor
  • 3
  • 2
  • 2
1 Solution
 
CEHJCommented:
Make it the argument to the construciton of a ByteArrayInputStream and then read that stream with an Excel API
0
 
cofactorAuthor Commented:
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
 
CEHJCommented:

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

Open in new window

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
objectsCommented:
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
 
objectsCommented:
or using the blob directly:

HSSFWorkbook wb     = new HSSFWorkbook(blob.getBinaryStream());
0
 
cofactorAuthor Commented:
excellent
0
 
cofactorAuthor Commented:
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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now