Error With creating an excel file from java POI

2020-05-09 09:16发布

Hi I would like to create an excel file from a java code, I put this code on eclipse but nothing happen

import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;

import java.io.FileOutputStream;

public class TestPOI1 {

     public static void main(String[] args) {
         //create the new workbook
         Workbook workbook = new HSSFWorkbook();

         try {
                 //create the output stream to save the document on the hard drive
                 FileOutputStream output = new FileOutputStream("Test1.xls");

                 //write the file onto the hard drive
                 workbook.write(output);

                 //finish it up by closing the document
                 output.close();
         } catch(Exception e) {
                 e.printStackTrace();
         }   
    }        
}

in the console, this message is written

 Usage: BiffDrawingToXml [options] inputWorkbook Options:
 -exclude-workbook exclude workbook-level records
 -sheet-indexes output sheets with specified indexes
 -sheet-namek output sheets with specified name

and I can't found my excel file in the hard drive or in the file project. thanks for help.

0条回答
登录 后发表回答