Quantcast
Channel: Comments on: Read / Write Excel file in Java using Apache POI
Viewing all 241 articles
Browse latest View live

By: Santhanam

$
0
0

hi patel i just copied your Update Existing Excel File and run it in netbeans ide.when i run it shows the following error,
Exception in thread “main” java.lang.IllegalArgumentException: Sheet index (0) is out of range (0..-1)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.validateSheetIndex(HSSFWorkbook.java:429)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.getSheetAt(HSSFWorkbook.java:825)
at com.infomindz.io.ReadXlFile.updateExistingFile(ReadXlFile.java:277)
at com.infomindz.io.ReadXlFile.main(ReadXlFile.java:308)

and the code is

String path = separator + "home" + separator + "santhanam" + separator+ "Contact list.xls";        FileInputStream inStream = new FileInputStream(path);
        HSSFWorkbook workbook = new HSSFWorkbook();
        HSSFSheet sheet = workbook.getSheetAt(0);
        Cell cell = null;

        //going to update existing excel file
        cell = sheet.getRow(1).getCell(2);
        cell.setCellValue(cell.getNumericCellValue() * 2);
        
        cell = sheet.getRow(2).getCell(2);
        cell.setCellValue(cell.getNumericCellValue() * 2);
        
        cell = sheet.getRow(3).getCell(2);
        cell.setCellValue(cell.getNumericCellValue() * 2);
        
        inStream.close();
        
        FileOutputStream out = new FileOutputStream(path);
        workbook.write(out);
        System.out.println("Updating Excell file successful");       

and also i checked xl file values.it is contain same value as what you gave.

if i did anything wrong pls advice me.
thanks in advance


By: Abcd

$
0
0

Sir ,where i add my downloaded poi in project .can u plz tell the complete structure of the project after adding the POI……Thanks

By: Amit Jain

$
0
0

In eclipse u can download and add in build path
like Go to Project > Properties > Java Build Path
Click and browse external jar where it is saved

If u have created a shared path for all external jars with environment variable M2_REPO then you can browse that path
C:\Users\<>\.m2\repository\

By: anand

$
0
0

nice, u helped me. u explained in a better way.
thank u.

By: Souvik Sarkar

$
0
0

One should use TreeMap instead of HashMap. As there is no ordering, one can get the heading row not as the top row always.

By: sree harsha

$
0
0

excellent information.
I will download this api now and work on it. I wasted lot of time searching online about other alternatives but this api is awesome and easy to use.
thanks for sharing this tutorial with all of us..

By: swati saxena

$
0
0

Solve this error ::

The supplied spreadsheet seems to be Excel 5.0/7.0 (BIFF5) format. POI only supports BIFF8 format (from Excel versions 97/2000/XP/2003)

By: Osano Kevin

$
0
0

Hi Patel, am in a serious problem, i have a folder receiving data in excel format every day in every second. i need to read these excel files and parse to MySQL database(Apache POI am using). My program needs to go back to the same data source to update only new data in those existing excel files. I also need to generate real time graphs from this data fro the database.
Please help me.


By: Amol Patil

$
0
0

Hi Patel,
It might be helpful if you can explain how to setup this library to some beginners :)
let me help you here.

You need to follow following steps to get started with above examples

1. you need to download poi-2.5.1.jar(or in this case 3.8) jar file
2. You need to include this file in your projects class path
3. Create new java project in eclipse with auto generated main function
4. just copy and paste above code or and press ctrl+Shift+o and your ready to go
Hope this helps :)

Amol Patil
findnetinfo.com

By: Amol Patil

$
0
0

and yes this is most helpful resource I found on internet about using these libraries thanks a ton..

for my previous comment , I was a complete newbie in reading xls and I faced problems while setting up all of it thats why explained this stuff but I found most of your readers expert here . :D

By: Viral Patel

$
0
0

@Amol: I am using Maven in this tutorial as specified in Step 1. That should add required dependencies. But thanks for your suggestion. I have added these steps to above tutorial so that users who do not wish to use Maven can run the examples without getting into classpath errors. Thanks :)

By: jarkema

$
0
0

Your example: Read Excel File using Eclipse worked fine on windows 7 for me. The only difficulty that I’m having is getting the docs to be accessed by Eclipse. I get “Note: This element neither has attached source nor attached Javadoc and hence no Javadoc could be found”. I added the source docs in as part of the Referenced Libraries along with the class .jar file. I can access the docs separately just fine, but haven’t been able to use them in code assist.

By: radha

$
0
0

hi your examples are simply good…
my requirement is i want to read data from one excel and i want to append it in another excel.
can you please guide me.

By: Ronnie

$
0
0

Im getting the following error:

org.apache.poi.poifs.filesystem.OfficeXmlFileException: The supplied data appears to be in the Office 2007+ XML. You are calling the part of POI that deals with OLE2 Office Documents. You need to call a different part of POI to process this data (eg XSSF instead of HSSF)

How do i resolve this?

By: Ronnie

$
0
0

The file was in .xlsx format. Converted it to .xls and now its working fine. Thank you.


By: Vaigha

$
0
0

How to add an image(logo) into an excel file using poi api?

By: prasad

$
0
0

Hi, I am reading table from db and storing it in excel I have more than one million records in the table. I want to store the records 1 lakh each in different excel file tabs not in the single excel file. Please let me know the procedure to get it stored in the excel with best efficient way.

By: Ronnie

$
0
0

Hi,
Doesn’t Apache POI read .xlsx files?

By: Ronnie

$
0
0

This is the error that im getting when i try to read an .xlsx file:

org.apache.poi.poifs.filesystem.OfficeXmlFileException: The supplied data appears to be in the Office 2007+ XML. You are calling the part of POI that deals with OLE2 Office Documents. You need to call a different part of POI to process this data (eg XSSF instead of HSSF)

By: hitish

$
0
0

In creating new excel file you must use treemap instead of hashmap because hashmap does not gurantee any order and elements are being printed randomly.

Viewing all 241 articles
Browse latest View live