Bug 41248 - Import into Access Fails
Summary: Import into Access Fails
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 2.5-FINAL
Hardware: Other Windows XP
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
Depends on:
Reported: 2006-12-27 20:28 UTC by Chris Barlock
Modified: 2008-05-10 20:01 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Chris Barlock 2006-12-27 20:28:04 UTC
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 = { 
            //"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++) {

        // Write a row of data.
        short k = 0;
        row = sheet.createRow(1);
        cell = row.createCell(k++);
        cell = row.createCell(k++);
        //cell = row.createCell(k++);
        String outputFileName = "test.xls";
        FileOutputStream fos = new FileOutputStream(outputFileName);
Comment 1 Avik Sengupta 2007-01-03 06:24:25 UTC
Given that there is no spec, different implementations will have different
interpretations of what's required for a valid file. Our effort has been to
ensure that files created by POI get read correctly in Excel. And vice versa. I
guess that supporting other implementations of the format will be too difficult
a task for the current dev team. If someone can however, debug this and say
which records are causing the problem, it might get a fix.  

Sorry, just trying to be realistic. 
Comment 2 Josh Micich 2008-05-10 20:01:50 UTC
Marking as "won't fix" because POI's primary goal is to be inter-operable with Excel.  Feel free to submit a patch which would allow Access to read the file without the intermediate re-save by Excel (as long as the first goal is preserved)