添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
失恋的白开水  ·  Cellular senescence ...·  2 天前    · 
冷静的火车  ·  Sis1 potentiates the ...·  4 月前    · 
大气的海龟  ·  vsto excel ...·  5 月前    · 
发财的李子  ·  现代FE Fuel ...·  1 年前    · 
谦和的马克杯  ·  DNA methylation of ...·  1 年前    · 
任性的枇杷  ·  OSS 文件&文件夹 ...·  1 年前    · 
长情的大脸猫  ·  INTERSECT function ...·  1 年前    · 
干练的西装  ·  React-router - ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams private static Workbook wb; private static FileOutputStream fos; private static FileInputStream fis; private static org.apache.poi.ss.usermodel.Sheet sh; private static Row row; private static Cell cell; public static void main(String[] args) throws Exception { fis = new FileInputStream("./javabook.xlsx"); wb = WorkbookFactory.create(fis); sh = wb.getSheet("Sheet1"); row =sh.getRow(1); cell = row.createCell(0); cell.setCellValue("ibrahim1"); fos = new FileOutputStream("./javabook.xlsx"); wb.write(fos); fos.close(); System.out.println("Done");

It worked for the first time and the text "ibrahim01" has appeared on the cell However when i ran it the second time i got this error:-

 Exception in thread "main" org.apache.poi.EmptyFileException: The supplied file was empty (zero bytes long)
at org.apache.poi.util.IOUtils.peekFirstNBytes(IOUtils.java:74)
at org.apache.poi.util.IOUtils.peekFirst8Bytes(IOUtils.java:57)
at org.apache.poi.poifs.filesystem.FileMagic.valueOf(FileMagic.java:135)
at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:177)
at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:149)
at package1.ClassA1.main(ClassA1.java:25)

picture of error when i open the file(javabook.xlsx) enter image description here

import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; public class ClassA1 { private static XSSFWorkbook wb; private static FileOutputStream fos; private static XSSFSheet sh; private static Row row; private static Cell cell; public static void main(String[] args) throws Exception { wb = new XSSFWorkbook(); sh = wb.createSheet("Sheet1"); row = sh.createRow(0); cell = row.createCell(0); cell.setCellValue("ibrahim1"); fos = new FileOutputStream("./javabook.xlsx"); wb.write(fos); fos.close(); System.out.println("Done");

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.