DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=41248>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=41248

           Summary: Import into Access Fails
           Product: POI
           Version: 2.5
          Platform: Other
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: HSSF
        AssignedTo: poi-dev@jakarta.apache.org
        ReportedBy: [EMAIL PROTECTED]


I have the following test program that generates an XLS file with two 
columns.  If I try to import this XLS into Microsoft Access 2003 (File > 
Get External Data > Import) only the first column shows in the Access 
dialog listing the data to be imported.  If I change the XLS to have three 
columns, all three show up!  Also, if I open the generated XLS file and save 
it, it imports into Access without error.  

Is this a bug in my program, or a bug in the HSSF classes? (I posted to the 
POI users mailing list, but no response.)

import java.io.FileOutputStream;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;

public class Test2 {
    public static void main(String[] args) throws Exception {
        final String[] header = { 
            "a",
            "b",
            //"b", "c"
        };
 
        HSSFWorkbook wb = new HSSFWorkbook();
        HSSFSheet sheet = wb.createSheet("Sheet 1");
        HSSFRow row;
        HSSFCell cell; 
        HSSFWorkbook hssfwb = new HSSFWorkbook();

        // Write the header.
        row = sheet.createRow(0);
        for (short j = 0; j < header.length; j++) {
            row.createCell(j).setCellValue(header[j]);
        }

        // Write a row of data.
        short k = 0;
        row = sheet.createRow(1);
        cell = row.createCell(k++);
        cell.setCellValue("a_value");
        cell = row.createCell(k++);
        cell.setCellValue("b_value");
        //cell = row.createCell(k++);
        //cell.setCellValue("c_value");
 
        String outputFileName = "test.xls";
        FileOutputStream fos = new FileOutputStream(outputFileName);
        wb.write(fos);
        fos.close();
    }
}

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
Mailing List:    http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta POI Project: http://jakarta.apache.org/poi/

Reply via email to