Bug 47661 - Lost data after opening and saving as another file
Summary: Lost data after opening and saving as another file
Status: RESOLVED WORKSFORME
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.5-dev
Hardware: PC Windows XP
: P1 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-08-07 03:58 UTC by Duc Nguyen
Modified: 2015-05-19 19:37 UTC (History)
1 user (show)



Attachments
Excel file input (75.50 KB, application/vnd.ms-excel)
2009-08-07 03:58 UTC, Duc Nguyen
Details
Excel file output (80.50 KB, application/vnd.ms-excel)
2009-08-07 03:59 UTC, Duc Nguyen
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Duc Nguyen 2009-08-07 03:58:21 UTC
Created attachment 24118 [details]
Excel file input

I downloaded the package "POI 3.5 beta 6, and Office Open XML Support
(2009-06-22)".

I have a input file "testcase.xls", I tried to open and save as another file
"newfile.xls" by POI. There is some problem when I open the file "newfile.xls"
  1. When I open "newfile.xls" by MS Office 2003, I got the message: "File
error: data may have been lost" before I am able to completely open the file.
But some cells (from F57 to L57) in sheet "Generator" can't show exactly value
like the origin input file "testcase.xls".
  2. I try to open by Open Office 3.0.0, there are many cells not able to show
exactly value like the origin file. For example: cells from F57 to L57 show
value "#NAME?", cells from E49 to L49 show value "#N/A".

Here is my source code:

import org.junit.Test;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;

public class ReadWriteSpeadsheetTest {

    @Test
    public void openSpreadsheet() {
        HSSFWorkbook wb = null;
        try {
            String xls = "input/testcase.xls";
            wb = new HSSFWorkbook(
                    new POIFSFileSystem(new FileInputStream(xls)));

            // Save as another file
            FileOutputStream fileOut = new FileOutputStream(
                    "output/newfile.xls");
            wb.write(fileOut);
            fileOut.close();

        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
Comment 1 Duc Nguyen 2009-08-07 03:59:14 UTC
Created attachment 24119 [details]
Excel file output
Comment 2 Dominik Stadler 2015-05-19 19:37:50 UTC
This seems to work fine with current versions of POI (at least LibreOffice displays the re-written file correctly, couldn't check on Excel), therefore I am closing this as WORKSFORME, please reopen this with updated information if it is still a problem for you.