当前位置: 技术问答>java相关
项目中需要生成EXCEL文件,求例子
来源: 互联网 发布时间:2015-11-11
本文导语: 项目中需要生成EXCEL文件,求例子 | import org.apache.poi.hssf.usermodel.HSSFWorkbook; import java.io.FileOutputStream; import java.io.IOException; /** * This example creates a new blank workbook. This workbook will conta...
项目中需要生成EXCEL文件,求例子
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import java.io.FileOutputStream;
import java.io.IOException;
/**
* This example creates a new blank workbook. This workbook will contain a single blank sheet.
*
* @author Glen Stampoultzis (glens at apache.org)
*/
public class NewWorkbook
{
public static void main(String[] args)
throws IOException
{
HSSFWorkbook wb = new HSSFWorkbook();
FileOutputStream fileOut = new FileOutputStream("workbook.xls");
wb.write(fileOut);
fileOut.close();
}
}
import java.io.FileOutputStream;
import java.io.IOException;
/**
* This example creates a new blank workbook. This workbook will contain a single blank sheet.
*
* @author Glen Stampoultzis (glens at apache.org)
*/
public class NewWorkbook
{
public static void main(String[] args)
throws IOException
{
HSSFWorkbook wb = new HSSFWorkbook();
FileOutputStream fileOut = new FileOutputStream("workbook.xls");
wb.write(fileOut);
fileOut.close();
}
}