|
|
@ -96,43 +96,23 @@ public class PoiTest { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void cp() throws IOException, InvalidFormatException { |
|
|
|
public void cp() throws IOException, InvalidFormatException { |
|
|
|
String file = "d://test/tt.xlsx"; |
|
|
|
String file = "d://test/tt.xlsx"; |
|
|
|
XSSFWorkbook xssfWorkbook = new XSSFWorkbook(new File(file)); |
|
|
|
SXSSFWorkbook xssfWorkbook = new SXSSFWorkbook(new XSSFWorkbook(file)); |
|
|
|
XSSFSheet xssfSheet = xssfWorkbook.getSheetAt(0); |
|
|
|
SXSSFSheet xssfSheet = xssfWorkbook.getSheetAt(0); |
|
|
|
XSSFRow row = xssfSheet.getRow(2); |
|
|
|
LOGGER.info("一共行数:{}", xssfSheet.getLastRowNum()); |
|
|
|
xssfSheet.removeRow(row); |
|
|
|
SXSSFRow row = xssfSheet.getRow(0); |
|
|
|
// Row r2= xssfSheet.createRow(2);
|
|
|
|
LOGGER.info("第一行数据:{}", row); |
|
|
|
// r2.createCell(1);
|
|
|
|
xssfSheet.createRow(20); |
|
|
|
SXSSFWorkbook sxssfWorkbook = new SXSSFWorkbook(xssfWorkbook); |
|
|
|
LOGGER.info("一共行数:{}", xssfSheet.getLastRowNum()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SXSSFSheet sxssfSheet = sxssfWorkbook.getSheetAt(0); |
|
|
|
|
|
|
|
sxssfSheet.createRow(2); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FileOutputStream fileout = new FileOutputStream("d://test/r2" + System.currentTimeMillis() + ".xlsx"); |
|
|
|
|
|
|
|
sxssfWorkbook.write(fileout); |
|
|
|
|
|
|
|
sxssfWorkbook.dispose(); |
|
|
|
|
|
|
|
sxssfWorkbook.close(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xssfWorkbook.close(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void lastRowNum233443() throws IOException, InvalidFormatException { |
|
|
|
public void lastRowNum233443() throws IOException, InvalidFormatException { |
|
|
|
String file = "d://test/tt.xlsx"; |
|
|
|
String file = "d://test/em0.xlsx"; |
|
|
|
XSSFWorkbook xssfWorkbook = new XSSFWorkbook(new File(file)); |
|
|
|
XSSFWorkbook xssfWorkbook = new XSSFWorkbook(new File(file)); |
|
|
|
SXSSFWorkbook sxssfWorkbook = new SXSSFWorkbook(xssfWorkbook); |
|
|
|
|
|
|
|
XSSFSheet xssfSheet = xssfWorkbook.getSheetAt(0); |
|
|
|
XSSFSheet xssfSheet = xssfWorkbook.getSheetAt(0); |
|
|
|
XSSFRow row = xssfSheet.getRow(2); |
|
|
|
System.out.println(xssfSheet.getLastRowNum()); |
|
|
|
xssfSheet.removeRow(row); |
|
|
|
System.out.println(xssfSheet.getRow(0)); |
|
|
|
new CellCopyPolicy().createBuilder().build(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FileOutputStream fileout = new FileOutputStream("d://test/r2" + System.currentTimeMillis() + ".xlsx"); |
|
|
|
|
|
|
|
sxssfWorkbook.write(fileout); |
|
|
|
|
|
|
|
sxssfWorkbook.dispose(); |
|
|
|
|
|
|
|
sxssfWorkbook.close(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xssfWorkbook.close(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|