从java导出excel文件怎么打开|java代码怎么导出excel文件

从java导出excel文件怎么打开|java代码怎么导出excel文件的第1张示图

① java导入大excel文件怎么打开

你是刚开始把excel的流读取的时候就内存溢出了吗?我建议如果内存吃紧 增加jvm启动内存 程序中及时释放内存,比如,excel中读取一行后,就把这一行保存到数据库,然后java内设置为null,让GC释放内存。然后一些list之类的,不用了也clear+setNul…

② java怎么导出excel

/** *负责数据导入到EXCEL * * @param realPath * EXCEL表格存放的绝对路径 * @param sheetname * * @param xLocation * EXCEL表格的行索引,从1开始 * @param yLocation * EXCEL表格的列索引,从1开始 * @param value * 需要导入的数据 * */ public void modifyExcel(String realPath,String sheetname,int xLocaion,int yLocation,String value){ POIFSFileSystem fs=null; HSSFWorkbook wb=null; try { File file=new File(realPath); if(file.exists()){ fs = new POIFSFileSystem(new FileInputStream(realPath)); wb=new HSSFWorkbook(fs); HSSFSheet s=wb.getSheetAt(0); //函数处理时横纵坐标从索引0开始 HSSFRow row=s.getRow(xLocaion-1); HSSFCell cell=null; if(row!=null){ cell=row.getCell(yLocation-1); if(cell==null){ cell=row.createCell(yLocation-1); } }else{ row=s.createRow(xLocaion-1); cell=row.createCell(yLocation-1); } cell.setCellValue(value); }else{ wb=new HSSFWorkbook(); HSSFSheet s=wb.createSheet(); wb.setSheetName(0, sheetname); HSSFRow row=s.createRow(xLocaion-1); HSSFCell cell=row.createCell(yLocation-1); cell.setCellValue(value); } FileOutputStream fos=new FileOutputStream(realPath); wb.write(fos); fos.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } 第二种就是运用了对象,以对象为单位写入数据,即一个对象的所有属性在一行列出,有多少个对象就有多少行,此方法比较适用于个人信息导出之类的应用,至于导出属性的顺序问题在导出对象的实体类内部改动下即可: /** *负责数据导入到EXCEL * * @param realPath * EXCEL表格存放的绝对路径 * @param sheetname * * @param users * 需要导出到excel表的对象数组 */ public void outputExcel(String realPath,String sheetname,UserModel[] users){ FileOutputStream fos; try { File file=new File(realPath); fos = new FileOutputStream(file, true); HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet s=wb.createSheet(); wb.setSheetName(0, sheetname); HSSFRow[] rows=new HSSFRow[users.length]; HSSFCell[][] cells=new HSSFCell[20][20]; for (int i=0; i<users.length;i++) { // 相当于excel表格中的总行数 PropertyDescriptor[] descriptors=(users[i]); rows[i]=s.createRow(i); for (int j=0; descriptors!=null&&j<descriptors.length;j++) { java.lang.reflect.Method readMethod = descriptors[j] .getReadMethod(); cells[i][j]=rows[i].createCell(j); Object value=readMethod.invoke(users[i], null); cells[i][j].setCellValue(value.toString()); } } wb.write(fos); fos.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } }

③ 用java导入excel文件怎么打开

用poi,你网络一下:java的poi技术读取Excel[2003-2007,2010]这个帖子讲的很清楚

④ java怎样输出excel文件

//java生成简单的Excel文件packagebeans.excel;importjava.io.IOException;importjava.io.OutputStream;importjxl.Workbook;importjxl.write.Label;importjxl.write.WritableSheet;importjxl.write.WritableWorkbook;importjxl.write.WriteException;publicclassSimpleExcelWrite{publicvoidcreateExcel(OutputStreamos)throwsWriteException,IOException{//创建工作薄WritableWorkbookworkbook=Workbook.createWorkbook(os);//创建新的一页WritableSheetsheet=workbook.createSheet("FirstSheet",0);//创建要显示的内容,创建一个单元格,第一个参数为列坐标,第二个参数为行坐标,第三个参数为内容Labelxuexiao=newLabel(0,0,"学校");sheet.addCell(xuexiao);Labelzhuanye=newLabel(1,0,"专业");sheet.addCell(zhuanye);Labeljingzhengli=newLabel(2,0,"专业竞争力");sheet.addCell(jingzhengli);Labelqinghua=newLabel(0,1,"清华大学");sheet.addCell(qinghua);Labeljisuanji=newLabel(1,1,"计算机专业");sheet.addCell(jisuanji);Labelgao=newLabel(2,1,"高");sheet.addCell(gao);Labelbeida=newLabel(0,2,"北京大学");sheet.addCell(beida);Labelfalv=newLabel(1,2,"法律专业");sheet.addCell(falv);Labelzhong=newLabel(2,2,"中");sheet.addCell(zhong);Labelligong=newLabel(0,3,"北京理工大学");sheet.addCell(ligong);Labelhangkong=newLabel(1,3,"航空专业");sheet.addCell(hangkong);Labeldi=newLabel(2,3,"低");sheet.addCell(di);//把创建的内容写入到输出流中,并关闭输出流workbook.write();workbook.close();os.close();}}

⑤ java用poi导出excel文件,打开导出的文件时报错,怎么办

两个原因:

1.你的excel模版本身有问题,可以尝试新建一个模版。

2.你的excel使用了一些POI不支持的函数。

解决办法:

另存是由excel重写了完整的文件,可以解决问题。

关闭文件例子:

FileOutputStream os = new FileOutputStream("workbook.xls");

wb.write(os);

os.close();

⑥ java怎么导出excel表格

通过这个例子,演示以下如何用java生成excel文件:import org.apache.poi.hssf.usermodel.*;import java.io.FileOutputStream;import java.io.IOException;publicclass CreateCells{publicstaticvoid main(String[] args)throws IOException{HSSFWorkbook wb = new HSSFWorkbook();//建立新HSSFWorkbook对象HSSFSheet sheet = wb.createSheet("new sheet");//建立新的sheet对象// Create a row and put some cells in it. Rows are 0 based.HSSFRow row = sheet.createRow((short)0);//建立新行// Create a cell and put a value in it.HSSFCell cell = row.createCell((short)0);//建立新cellcell.setCellValue(1);//设置cell的整数类型的值// Or do it on one line.row.createCell((short)1).setCellValue(1.2);//设置cell浮点类型的值row.createCell((short)2).setCellValue("test");//设置cell字符类型的值row.createCell((short)3).setCellValue(true);//设置cell布尔类型的值HSSFCellStyle cellStyle = wb.createCellStyle();//建立新的cell样式cellStyle.setDataFormat(HSSFDataFormat.getFormat("m/d/yy h:mm"));//设置cell样式为定制的日期格式HSSFCell dCell =row.createCell((short)4);dCell.setCellValue(new Date());//设置cell为日期类型的值dCell.setCellStyle(cellStyle); //设置该cell日期的显示格式HSSFCell csCell =row.createCell((short)5);csCell.setEncoding(HSSFCell.ENCODING_UTF_16);//设置cell编码解决中文高位字节截断csCell.setCellValue("中文测试_Chinese Words Test");//设置中西文结合字符串row.createCell((short)6).setCellType(HSSFCell.CELL_TYPE_ERROR);//建立错误cell// Write the output to a fileFileOutputStream fileOut = new FileOutputStream("workbook.xls");wb.write(fileOut);fileOut.close();}}

⑦ 急!!!java用poi导出excel文件,打开导出的文件时报错“文件错误,数据可能丢失”

用java写完文件后需要关闭文件流,如果不关闭就会报这个错。因为你的文件内容写完了,所以内容没有缺失,但excel检测到文件没有正常结束,所以报错。另存是由excel重写了完整的文件,所以可以解决问题。关闭文件例子:FileOutputStream os = new FileOutputStream("workbook.xls");wb.write(os);os.close();

⑧ java代码怎么导出excel文件

excel工具类package com.ohd.ie.proct.action;import java.awt.image.BufferedImage;import java.io.*;import javax.imageio.ImageIO;import org.apache.commons.io.output.ByteArrayOutputStream;import jxl.Workbook;import jxl.format.Alignment;import jxl.format.VerticalAlignment;import jxl.write.*;import jxl.write.Number;import jxl.write.biff.RowsExceededException;public class Excel {private OutputStream os;private WritableWorkbook wwb = null;private WritableSheet ws = null;private WritableCellFormat titleCellFormat = null;private WritableCellFormat noBorderCellFormat = null;private WritableCellFormat hasBorderCellFormat = null;private WritableCellFormat hasBorderCellNumberFormat = null;private WritableCellFormat hasBorderCellNumberFormat2 = null;private WritableImage writableImage=null;private int r;public Excel(OutputStream os){this.os = os;r = -1;try {wwb = Workbook.createWorkbook(os);//创建工作表ws = wwb.createSheet("sheet1",0);//设置表头字体,大小,加粗titleCellFormat = new WritableCellFormat();titleCellFormat.setAlignment(Alignment.CENTRE);titleCellFormat.setVerticalAlignment(VerticalAlignment.CENTRE);//自动换行titleCellFormat.setWrap(true);titleCellFormat.setFont(new WritableFont(WritableFont.createFont("宋体"),12,WritableFont.BOLD));titleCellFormat.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN);//设置表格字体,大小—-无边框noBorderCellFormat = new WritableCellFormat();noBorderCellFormat.setAlignment(Alignment.CENTRE);noBorderCellFormat.setVerticalAlignment(VerticalAlignment.CENTRE);noBorderCellFormat.setFont(new WritableFont(WritableFont.createFont("宋体"),12));//设置表格字体,大小—-有边框hasBorderCellFormat = new WritableCellFormat();hasBorderCellFormat.setAlignment(Alignment.CENTRE);hasBorderCellFormat.setVerticalAlignment(VerticalAlignment.CENTRE);hasBorderCellFormat.setFont(new WritableFont(WritableFont.createFont("宋体"),12));hasBorderCellFormat.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN);//设置表格字体,大小—-有边框(小数)NumberFormat nf = new NumberFormat("#0.00");hasBorderCellNumberFormat = new WritableCellFormat(nf);hasBorderCellNumberFormat.setAlignment(Alignment.CENTRE);hasBorderCellNumberFormat.setVerticalAlignment(VerticalAlignment.CENTRE);hasBorderCellNumberFormat.setFont(new WritableFont(WritableFont.createFont("宋体"),12));hasBorderCellNumberFormat.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN);//设置表格字体,大小—-有边框(整数)NumberFormat nf2 = new NumberFormat("#0");hasBorderCellNumberFormat2 = new WritableCellFormat(nf2);hasBorderCellNumberFormat2.setAlignment(Alignment.CENTRE);hasBorderCellNumberFormat2.setVerticalAlignment(VerticalAlignment.CENTRE);hasBorderCellNumberFormat2.setFont(new WritableFont(WritableFont.createFont("宋体"),12));hasBorderCellNumberFormat2.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN);} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();}}/**** @param content 内容* @param c 列* @param style 样式* @param isNewLine 是否换行* @param mergeType 合并类型* @param mergeCount 合并个数* @param width 单元格宽*/public void setExcelCell(String content,int c,int style,boolean isNewLine,int mergeType,int mergeCount,int width){try {////////////////////////////////////////////////////////////////////////////////////////////////////////////////////报表内容////////////////////////////////////////////////////////////////////////////////////////////////////////////////////if(isNewLine){r++;}WritableCell l = null;if(style == 1){l = new Label(c,r,content,titleCellFormat);}else if(style == 2){l = new Label(c,r,content,noBorderCellFormat);}else if(style == 3){l = new Label(c,r,content,hasBorderCellFormat);}else if(style == 4){l = new Number(c,r,Double.parseDouble(content),hasBorderCellNumberFormat);}else if(style == 5){l = new Number(c,r,Integer.parseInt(content),hasBorderCellNumberFormat2);}ws.addCell(l);if(width != 0){ws.setColumnView(c,width);}//veryhuo,comif(mergeType == 1){//x 轴方向ws.mergeCells(c, r, c+mergeCount-1 , r);}else if(mergeType == 2){//y 轴方向ws.mergeCells(c, r, c, r+mergeCount-1);}if(isNewLine){ws.setRowView(r, 350);if(style == 1 && r != 0){ws.setRowView(r, 900);}else{ws.setRowView(r, 350);}}//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////} catch (Exception e) {System.out.println(e.toString());}}public void setExcelCellEx(String content,int c,int style,boolean isNewLine,int mergeType,int mergeCount,int width,int row){try {////////////////////////////////////////////////////////////////////////////////////////////////////////////////////报表内容////////////////////////////////////////////////////////////////////////////////////////////////////////////////////if(isNewLine){r++;}WritableCell l = null;if(style == 1){l = new Label(c,r,content,titleCellFormat);}else if(style == 2){l = new Label(c,r,content,noBorderCellFormat);}else if(style == 3){if(content.indexOf(".jpg")!=-1 ||content.indexOf(".JPG")!=-1){File outputFile=null;File imgFile =new File(content);if(imgFile.exists()&&imgFile.length()>0){BufferedImage input=null;try {input = ImageIO.read(imgFile);} catch (Exception e) {e.printStackTrace();}if(input!=null){String path=imgFile.getAbsolutePath();outputFile = new File(path.substring(0,path.lastIndexOf('.')+1)+"png");ImageIO.write(input, "PNG", outputFile);if(outputFile.exists()&&outputFile.length()>0){ws.setRowView(row,2000);//ws.setColumnView(8, 10);writableImage = new WritableImage(c+0.1, row+0.1, 0.8, 0.8, outputFile);ws.addImage(writableImage);l = new Label(c,r,"",hasBorderCellFormat);}}}}else{l = new Label(c,r,content,hasBorderCellFormat);}}else if(style == 4){l = new Number(c,r,Double.parseDouble(content),hasBorderCellNumberFormat);}else if(style == 5){l = new Number(c,r,Integer.parseInt(content),hasBorderCellNumberFormat2);}ws.addCell(l);if(width != 0){ws.setColumnView(c,width);}if(mergeType == 1){//x 轴方向ws.mergeCells(c, r, c+mergeCount-1 , r);}else if(mergeType == 2){//y 轴方向ws.mergeCells(c, r, c, r+mergeCount-1);}if(isNewLine){ws.setRowView(r, 350);if(style == 1 && r != 0){ws.setRowView(r, 900);}else{ws.setRowView(r, 350);}}} catch (Exception e) {System.out.println(e.toString());}}public void setRowHeight(int val){try {ws.setRowView(r, val);} catch (RowsExceededException e) {e.printStackTrace();}}public void getExcelResult(){try {wwb.write();} catch (Exception e) {System.out.println(e.toString());}finally{if(wwb != null){try {wwb.close();if(os != null){os.close();}} catch (WriteException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();}}}}}需要的jar包:jxl.jar

⑨ 如何从java输出到excel

用JAVA程序,读取或者写入excel文件,通过用jxl或者poi,下面是我给你写的例子。分别是用jxl读写excel文件,用poi读写excel文件。希望对你有帮助。(需要下载jxl和poi的jar包)package util.excel;import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.IOException;import java.util.ArrayList;import java.util.HashMap;import java.util.List;import java.util.Map;import jxl.Cell;import jxl.Sheet;import jxl.Workbook;import jxl.format.Colour;import jxl.format.UnderlineStyle;import jxl.write.Label;import jxl.write.WritableCellFormat;import jxl.write.WritableFont;import jxl.write.WritableSheet;import jxl.write.WritableWorkbook;import org.apache.poi.hssf.usermodel.HSSFCell;import org.apache.poi.hssf.usermodel.HSSFRichTextString;import org.apache.poi.hssf.usermodel.HSSFRow;import org.apache.poi.hssf.usermodel.HSSFSheet;import org.apache.poi.hssf.usermodel.HSSFWorkbook;import org.apache.poi.poifs.filesystem.POIFSFileSystem;public class ExcelUtil { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { String outFile = "D:/workspace/JavaStudy/src/util/excel/test.xls"; ExcelUtil.writeExcelByJXL(outFile, null); } /** * * @title: readExcelByJXL * @description: 通过jxl读取excel文件 * @author yu ren tian * @email [email protected] * @param excelFile * @return * @throws IOException */ private static List readExcelByJXL(String excelFile) throws IOException { List rtn = new ArrayList(); FileInputStream fileInputStream = null; try { fileInputStream = new FileInputStream(excelFile); Workbook excelWorkBook = Workbook.getWorkbook(fileInputStream); Sheet sheet = excelWorkBook.getSheet(0); int m = sheet.getRows(); int n = sheet.getColumns(); for (int i = 1; i < m; i++) { Map map = new HashMap(); for (int j = 0; j < n; j++) { Cell cell = sheet.getCell(j, i); String cellContent = cell.getContents(); switch (j) { case 0: map.put("studentName", cellContent); break; case 1: map.put("Chinese", cellContent); break; case 2: map.put("Math", cellContent); break; case 3: map.put("English", cellContent); break; case 4: map.put("assess", cellContent); break; } } rtn.add(map); } } catch (Exception e) { e.printStackTrace(); } finally { if (null != fileInputStream) { fileInputStream.close(); } return rtn; } } /** * * @title: writeExcelByJXL * @description: 通过jxl写入excel文件 * @author yu ren tian * @email [email protected] * @param outFile * @param list * @throws IOException */ private static void writeExcelByJXL(String outFile, List list) throws IOException { WritableWorkbook wwb; FileOutputStream fos; try { fos = new FileOutputStream(outFile); // wwb = Workbook.createWorkbook(file); wwb = Workbook.createWorkbook(fos); WritableSheet sheet = wwb.createSheet("test", 0); // 设置单元格的文字格式 WritableFont wf = new WritableFont(WritableFont.ARIAL, 12, WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE, Colour.BLUE); WritableCellFormat wcf = new WritableCellFormat(wf); //wcf.setBackground(Colour.GREEN); wcf.setBackground(new CustomColor(11, "", 0, 0, 0)); for (int i = 0; i < 10; i++) { Label label = new Label(i, 0, i + "", wcf); sheet.addCell(label); } wwb.write(); wwb.close(); fos.close(); } catch (Exception e) { e.printStackTrace(); } } /** * * @title: readExcelByPOI * @description: 通过poi读取excel文件 * @author yu ren tian * @email [email protected] * @param excelFile * @return * @throws IOException */ private static List readExcelByPOI(String excelFile) throws IOException { List rtn = new ArrayList(); FileInputStream fin = null; try { fin = new FileInputStream(excelFile); POIFSFileSystem fs = new POIFSFileSystem(fin); HSSFWorkbook wb = new HSSFWorkbook(fs); HSSFSheet sheet = wb.getSheetAt(0); int m = sheet.getLastRowNum() – sheet.getFirstRowNum() + 1; int n = 5; for (int i = 1; i < m; i++) { Map map = new HashMap(); for (int j = 0; j < n; j++) { HSSFCell cell = sheet.getRow(i).getCell((short) j); int type = cell.getCellType(); String cellContentString = null; double cellContentDouble = 0; if (type == 1) { cellContentString = cell.getRichStringCellValue() .getString(); System.out.println("cellContentString=" + cellContentString); } else if (type == 0) { cellContentDouble = cell.getNumericCellValue(); System.out.println("cellContentDouble=" + cellContentDouble); } System.out.println("j=" + j); switch (j) { case 0: map.put("studentName", cellContentString); break; case 1: map.put("Chinese", new Double(cellContentDouble)); break; case 2: map.put("Math", new Double(cellContentDouble)); break; case 3: map.put("English", new Double(cellContentDouble)); break; case 4: map.put("assess", cellContentString); break; } } } } catch (Exception e) { e.printStackTrace(); } finally { if (fin != null) { fin.close(); } return rtn; } } /** * * @title: writeExcelByPOI * @description: 通过poi写入excel * @author yu ren tian * @email [email protected] * @param outFile * @param list * @throws IOException */ private static void writeExcelByPOI(String outFile, List list) throws IOException { FileOutputStream fos = new FileOutputStream(outFile); HSSFWorkbook wb = new HSSFWorkbook(); for (int sheetCount = 0; sheetCount < 5; sheetCount++) { HSSFSheet sheet = wb.createSheet("组织" + (sheetCount + 1)); for (int rowCount = 0; rowCount < 10; rowCount++) { for (int columnCount = 0; columnCount < 10; columnCount++) { HSSFRow row = sheet.createRow(rowCount); HSSFCell cell = row.createCell(new Short(columnCount + "")); HSSFRichTextString richTextString = new HSSFRichTextString( "行=" + rowCount + " 列=" + columnCount); cell.setCellValue(richTextString); } } } wb.write(fos); }}

⑩ java导出excel,excel打不开,报文件格式无效,怎么解决!

两个原因:1.你的excel模版本身有问题,可以尝试新建一个模版。2.你的excel使用了一些POI不支持的函数。解决办法:另存是由excel重写了完整的文件,可以解决问题。关闭文件例子:FileOutputStream os = new FileOutputStream("workbook.xls");wb.write(os);os.close();在保护状态下execl的格式有可能正在被使用,你这边修改,准确说是线程冲突,一般excel值会作为导出文件的模板,是不会编辑的。你可以在读的时候判断execl是否正在被使用。下面的代码问题,你可以参考package com.hwt.glmf.common;import java.io.IOException;import java.io.OutputStream;import java.util.ArrayList;import java.util.List;import javax.servlet.http.HttpServletResponse;import org.apache.poi.hssf.usermodel.HSSFCell;import org.apache.poi.hssf.usermodel.HSSFCellStyle;import org.apache.poi.hssf.usermodel.HSSFFont;import org.apache.poi.hssf.usermodel.HSSFRichTextString;import org.apache.poi.hssf.usermodel.HSSFRow;import org.apache.poi.hssf.usermodel.HSSFSheet;import org.apache.poi.hssf.usermodel.HSSFWorkbook;import org.apache.poi.hssf.util.CellRangeAddress;import org.apache.poi.hssf.util.HSSFColor;/*** 导出Excel公共方法* @version 1.0** @author wangcp**/public class ExportExcel extends BaseAction {//显示的导出表的标题private String title;//导出表的列名private String[] rowName ;private List<Object[]> dataList = new ArrayList<Object[]>();HttpServletResponse response;//构造方法,传入要导出的数据public ExportExcel(String title,String[] rowName,List<Object[]> dataList){this.dataList = dataList;this.rowName = rowName;this.title = title;}/** 导出数据* */public void export() throws Exception{try{HSSFWorkbook workbook = new HSSFWorkbook(); // 创建工作簿对象HSSFSheet sheet = workbook.createSheet(title); // 创建工作表// 产生表格标题行HSSFRow rowm = sheet.createRow(0);HSSFCell cellTiltle = rowm.createCell(0);//sheet样式定义【getColumnTopStyle()/getStyle()均为自定义方法 – 在下面 – 可扩展】HSSFCellStyle columnTopStyle = this.getColumnTopStyle(workbook);//获取列头样式对象HSSFCellStyle style = this.getStyle(workbook); //单元格样式对象sheet.addMergedRegion(new CellRangeAddress(0, 1, 0, (rowName.length-1)));cellTiltle.setCellStyle(columnTopStyle);cellTiltle.setCellValue(title);// 定义所需列数int columnNum = rowName.length;HSSFRow rowRowName = sheet.createRow(2); // 在索引2的位置创建行(最顶端的行开始的第二行)// 将列头设置到sheet的单元格中for(int n=0;n<columnNum;n++){HSSFCell cellRowName = rowRowName.createCell(n); //创建列头对应个数的单元格cellRowName.setCellType(HSSFCell.CELL_TYPE_STRING); //设置列头单元格的数据类型HSSFRichTextString text = new HSSFRichTextString(rowName[n]);cellRowName.setCellValue(text); //设置列头单元格的值cellRowName.setCellStyle(columnTopStyle); //设置列头单元格样式}

未经允许不得转载:山九号 » 从java导出excel文件怎么打开|java代码怎么导出excel文件

赞 (0)