大佬教程收集整理的这篇文章主要介绍了如何不使用 POI 覆盖 Excel 中的现有值,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
嗨,我正在尝试写入附加的计算 SRF。我可以写入它并将数据放入正确的单元格中(感谢这个社区)。我遇到的问题是,每次向单元格添加新值时,我都会覆盖(创建新行)整行。
更新后的输出:
这是我到目前为止的代码:
public static voID writetoExcel(String[][] exportData,String filename,Integer learnerRow){
Integer @R_696_8620@ns = DataExport.aUnits.size();
Integer rows = Dataimport.rows_in_sheet[0]+4;
Integer rowNum = learnerRow+2;
DataFormatter formatter = new DataFormatter();
Integer[] exportRowIDx = {0};Integer[] exportColIDx = {0};Integer[] start = {0};
try {
XSSFWorkbook wb = null;
fileinputStream inp = new fileinputStream(fileName);
wb = (XSSFWorkbook) WorkbookFactory.create(inp);
XSSFSheet sheet = wb.getSheetAt(0);
XSSFRow row1 = sheet.getRow(18);//places the start row
XSSFRow row = sheet.getRow(0); if (row == null) row = sheet.createRow(0);
XSSFCell cell = row.getCell(2); if (cell == null) cell = row.createCell(2);
XSSFCell cell2 = row1.getCell(0); if (cell2 == null) cell2 = row.createCell(0);
for (int rowIDx = 0; rowIDx < rows; rowIDx++) {
row1 = sheet.getRow(rowIDX); if (row1 == null) row1 = sheet.createRow(rowIDX);
for (int cellIDx = 0; cellIDx < @R_696_8620@ns; cellIDx++) {
cell2 = row1.getCell(cellIDX); if (cell2 == null) cell2 = row1.createCell(cellIDX);
if (rowIDx >= rowNum && cellIDx > 0 ){
if(exportRowIDx[0] < exportData.length){
cell2.setCellValue(exportData[exportRowIDx[0]][exportColIDx[0]]);
exportColIDx[0]++;}
}
}
if(rowIDx > ROWNUM){
exportRowIDx[0]++;
}
exportColIDx[0] =0;
}
提前致谢
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
以上是大佬教程为你收集整理的如何不使用 POI 覆盖 Excel 中的现有值全部内容,希望文章能够帮你解决如何不使用 POI 覆盖 Excel 中的现有值所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。