Hi, You are welcome. Your code will slow down your program. When you use XSSFWorkbook() constructor POI do a lot of operations which are not needed for getting byte array(file parsing e.g.).
Regrads, Evgeniy Berlog On Fri, Jul 27, 2012 at 12:25 PM, elmodai <[email protected]> wrote: > Hi, thank you! > > your tip works fine. But I have a solution good to, look: > > FileInputStream ips = new FileInputStream(filePath); > XSSFWorkbook workb = new XSSFWorkbook(ips); > ByteArrayOutputStream bos = new ByteArrayOutputStream(); > workb.write(bos); > bos.close(); > byte[] store = bos.toByteArray(); > > I think is less complicated with POI. > > Thank you again teacher! > > On 7/27/12, Evgeniy Berlog [via Apache POI] > <[email protected]> wrote: > > > > > > Hi, > > It is not neccessary use POI to get content of Excel file. > > > > you can use such chunk of code: > > > > InputStream is = ... > > ByteArrayOutputStream buffer = new ByteArrayOutputStream(); > > > > int nRead; > > byte[] data = new byte[16384]; > > > > while ((nRead = is.read(data, 0, data.length)) != -1) { > > buffer.write(data, 0, nRead); > > } > > > > buffer.flush(); > > > > return buffer.toByteArray(); > > > > Regrads, Evgeniy Berlog > > > > On Fri, Jul 27, 2012 at 10:52 AM, elmodai <[email protected]> wrote: > > > >> Hi, > >> > >> I'd like to: > >> > >> 1. Read a file excel file from filesystem (disk) and store the data in > >> memory using byte array. > >> 2. then, write that content to another excel file that must be commited > >> on > >> a > >> SVN. > >> > >> I have tried it using pure Java, without libraries like POI. But I > >> couldn't > >> do it. > >> I have sucess doing it only with PDF and TXT files, because when I try > >> with > >> excel file, that fle was created damaged. > >> > >> Somebody can help me? I only need the explanation to extract the the > >> content > >> of excel files to byte array. > >> > >> thank you! > >> > >> > >> > >> -- > >> View this message in context: > >> > http://apache-poi.1045710.n5.nabble.com/Trying-to-read-extract-content-from-xlsx-xls-file-and-store-it-on-byte-array-tp5710544.html > >> Sent from the POI - User mailing list archive at Nabble.com. > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: [email protected] > >> For additional commands, e-mail: [email protected] > >> > >> > > > > > > > > > > _______________________________________________ > > If you reply to this email, your message will be added to the discussion > > below: > > > http://apache-poi.1045710.n5.nabble.com/Trying-to-read-extract-content-from-xlsx-xls-file-and-store-it-on-byte-array-tp5710544p5710546.html > > > > To unsubscribe from Trying to read/extract content from xlsx/xls file and > > store it on byte array, visit > > > http://apache-poi.1045710.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5710544&code=ZWxtb2RhaUBnbWFpbC5jb218NTcxMDU0NHwyMTM1MjQ5NDQ4 > > > > > -- > View this message in context: > http://apache-poi.1045710.n5.nabble.com/Trying-to-read-extract-content-from-xlsx-xls-file-and-store-it-on-byte-array-tp5710544p5710547.html > Sent from the POI - User mailing list archive at Nabble.com. >
