Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2438
  • 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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