I want to produce an excel file using Java and jxlapi. But it is not allowing me to use more than 256 columns. I want to increase the column limit to at least 1000.
I tried ApachePOI also but the same problem.It is not allowing me more than 256 columns.
Any insight on how to achieve this?
Here is my simple implementation of Apache POI which sends me into a never ending loop of importing libraries.. 🙁
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFCreationHelper;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFCell;
public class CreateExcel {
public static void main (String args[]) throws IOException {
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet = wb.createSheet("new sheet");
XSSFRow row1 = sheet.createRow((short)0);
XSSFRow row2 = sheet.createRow((short)0);
XSSFCell tempcell1 = row1.createCell(3);
tempcell1.setCellValue(1000);
FileOutputStream fileOut = new FileOutputStream("/home/abhishek/Desktop/workbook1.xls");
wb.write(fileOut);
fileOut.close();
}
}
JExcel (jxlapi) writes Excel files in the Excel 2000 file format (.XLS extension). This format is limited to 256 columns.
You might need to change to another library able to write Excel files in the Excel 2003 file format (.XLSX extension), which doesn’t have this limitation anymore.
Apache POI is able to write the newer file format if you use the classes in the org.apache.poi.ss.usermodel packages (instead of the org.apache.poi.hssf.usermodel package).