我有一个要求,我需要为给定时间段内的所有事务生成报告,我需要相应地应用单元格格式.在这种情况下,单元格格式化不起作用,特别是在工作表中创建32748单元格后的日期.这似乎是API中的错误,如果有人已经遇到此问题并发现任何修复,请提供一些输入.
供参考,以下是示例代码:
public class TestFormat {
public static void main(String args[]){
try {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("Excel Sheet");
HSSFDataFormat format = wb.createDataFormat();
for(int i = 1; i<65535;i++ ) {
HSSFRow row = sheet.createRow(i);
HSSFCell cell = row.createCell(1);
HSSFCellStyle style = wb.createCellStyle();
cell.setCellValue((Date) new Date());
style.setDataFormat(format.getFormat("MM/dd/yyyy HH:mm:ss"));
cell.setCellStyle(style);
}
FileOutputStream fileOut;
fileOut = new FileOutputStream("c:\\test\\excelFile.xls");
wb.write(fileOut);
fileOut.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("Data is saved in excel file.");
} …Run Code Online (Sandbox Code Playgroud) 我需要在单元格注释中添加多行.如何使用apache POI打破单元格注释中的行
例如:
Comment = "This is comment 1";
comment = comment + "This is comment2";
comment = comment + "This is comment3";
cell.setCellComment(comment);
Run Code Online (Sandbox Code Playgroud) 我正在使用 NPOI 库创建一个包含表格的 word 文件。如何设置表格的宽度和行/单元格格式?
在 POI 库中,他们说您必须使用 getCTTbl 和我在 NPOI 中找不到的其他方法/类。
我已经从 Maven 存储库下载了 poi -3.14 jar,但它有 hssf 的所有包,我需要 xssf 的 xlsx 格式。我应该在哪里下载 xssf jar。
SOLID_FOREGROUND cannot be resolved or is not a field
style.setFillPattern(CellStyle.SOLID_FOREGROUND);
Run Code Online (Sandbox Code Playgroud)
使用
我的3.7版本apache-poi遇到以下问题。请帮忙解决这个问题。
SOLID_FOREGROUND cannot be resolved or is not a field
Run Code Online (Sandbox Code Playgroud)
谢谢,戈瓦尔丹
如何在Groovy/POI中的test1.xls顶部插入整个空行?我非常接近完成我的项目,这是最后一块拼图.非常感谢您的帮助.
@Grab( 'org.apache.poi:poi:3.9' )
import static org.apache.poi.ss.usermodel.CellStyle.*
import static org.apache.poi.ss.usermodel.IndexedColors.*
import org.apache.poi.hssf.usermodel.HSSFWorkbook
import org.apache.poi.hssf.usermodel.*
import org.apache.poi.ss.usermodel.Cell
import org.apache.poi.ss.util.CellRangeAddress
// Open the spreadsheet
new File( 'C:\\test1.xls' ).withInputStream { ins ->
new HSSFWorkbook( ins ).with { workbook ->
getSheetAt( 0 ).with { sheet ->
getRow( 0 ).getCell( 0 ).setCellValue( 'ID' )
getRow( 0 ).getCell( 1 ).setCellValue( 'Start Date' )
getRow( 0 ).getCell( 2 ).setCellValue( 'End Date' )
getRow( 0 ).getCell( 3 ).setCellValue( 'Status' )
getRow( 0 ).getCell( 4 ).setCellValue( 'Instrusive' )
getRow( …Run Code Online (Sandbox Code Playgroud) 我有一个.csv文件,其中每列的数据格式如下
TEST;"TEST1";"TEST2";"TEST3";"TEST4"。
我需要将.csv文件转换为.xlsx文件,其中每个值应位于不同的列中。例如:参见附图。
我尝试使用 Apache POI,但它只是转换为.xlsx格式,但数据保留在一列中。
谁能分享一下示例代码吗?
csv 中的示例输入
下面是示例输出结果,应为 xlsx 格式。

目前我们实现了 poi 而不是 jxl,所以现在我想获取单元格内容并传递到一个方法中,直到最后一行
代码:
FileInputStream file = new FileInputStream(new File("F:\\AUT.xlsx"));
XSSFWorkbook workbook = new XSSFWorkbook(file);
XSSFSheet sheet = workbook.getSheetAt(0);
for (int row = 1; row <= sheet.getPhysicalNumberOfRows(); row++) {
String cellvalue =
}
Run Code Online (Sandbox Code Playgroud)
在 for 循环中收集第一行值并存储到 String 变量中并将此值传递给一个方法,然后循环继续到最后一行
让我知道如何使用 for 循环
我的 XWPFTableCell 需要一个边框,如下表所示。
**XXX Technologies**
Run Code Online (Sandbox Code Playgroud)
__________________
|姓名 |性别 |工资 |
__________________
拉吉女 24000
拉维男 06790
这是在apache POI导出的Excel文档中,我不知道这句话的意思是"这是在1/20的一点."; 谁能帮我!我知道这句话"1/20"是长度单位,但我不知道转换这个单位;