jxlapi 中用于从 Java 生成 excel 文件的列限制
我想使用 Java 和 jxlapi 生成一个 excel 文件。但它不允许我使用超过 256 列。我想将列限制增加到至少 1000。
我也尝试过 ApachePOI,但遇到同样的问题。它不允许我超过 256 列。
关于如何实现这一目标有什么见解吗?
这是我对 Apache POI 的简单实现,它让我陷入了导入库的永无休止的循环..:(
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();
}
}
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();
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
JExcel (jxlapi) 以 Excel 2000 文件格式(.XLS 扩展名)写入 Excel 文件。此格式限制为 256 列。
您可能需要更改为能够以 Excel 2003 文件格式(.XLSX 扩展名)写入 Excel 文件的另一个库,该库不再有此限制。
如果您使用 org.apache.poi.ss.usermodel 包中的类(而不是 org.apache.poi.hssf.usermodel),Apache POI 能够写入更新的文件格式 包)。
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).