- ·上一篇:excel表格里的背景颜色怎么去掉
- ·下一篇:excel表格中的游戏怎么编辑
list怎么转换成excel表格
1.如何将LIST对像导出EXCEL
首先这个List尽量是Object类型的,也就是:Listlist其次就是开始遍历这个listintcurrentRowNum=startRowNum-1;//从第几行开始写intcurrentColNum=startColNum-1;//从第几列开始写for(Object[]objects:list){//遍历listXSSFRowrow=sheet.createRow(currentRowNum);//一个list就是一行,创建一个行for(Objectobject:objects){//遍历每一个list的Object[]数组if(object==null){XSSFCellcell=row.createCell(currentColNum++,XSSFCell.CELL_TYPE_BLANK);//如果该单元格为空,则创建一个空格子,不然数据会移位cell.setCellValue("");//将这个空格设置为空字符串}elseif(||objectinstanceofFloat){//判断这个格子放的数据的类型,其他的同理XSSFCellcell=row.createCell(currentColNum++,XSSFCell.CELL_TYPE_NUMERIC);//如果是Double或者Float类型的,则用这个方式cell.setCellValue(Double.parseDouble(object.toString()));}elseif(objectinstanceofLong||){XSSFCellcell=row.createCell(currentColNum++,XSSFCell.CELL_TYPE_NUMERIC);cell.setCellValue(Double.parseDouble(object.toString()));}elseif(objectinstanceofDate){XSSFCellcell=row.createCell(currentColNum++,XSSFCell.CELL_TYPE_STRING);cell.setCellValue(newSimpleDateFormat("dd-MM-yyyy").format((Date)object));}elseif(){XSSFCellcell=row.createCell(currentColNum++,XSSFCell.CELL_TYPE_BOOLEAN);cell.setCellValue((Boolean)object);}else{XSSFCellcell=row.createCell(currentColNum++,XSSFCell.CELL_TYPE_STRING);cell.setCellValue(String.valueOf(object));}}currentRowNum++;//写完第一个list,跳到下一行currentColNum=startColNum-1;}这种是poi操作EXCEL的方法哈。
jxl操作略有不同。
2.c# list
///
3.关于在java中将一个list转成excel文件之后,并提供给客户端下载的问题
主要是response的输出流里面是你的内容。
给你一个我之前写的下载文件的例子,你参考试试看rout = response.getOutputStream();is=new BufferedInputStream(new FileInputStream(filePath));os = new BufferedOutputStream(rout);byte [] buff = new byte[2048];int byteRead;while(-1!=(byteRead = is.read(buff, 0, buff.length))){ os.write(buff,0,byteRead);}最后关闭流。return null。
4.vb 请问如何将listbox的内容转写到excel
先引用 Microsoft Excel x.0 object library
Dim xlApp As New Excel.Application
Dim xlBook As Excel.Workbook
Dim xlsheet As Excel.Worksheet
Set xlBook = xlApp.Workbooks.Open("路径.XLS") '打开要保存的excel
Set xlsheet = xlBook.Worksheets(1)
For i = 0 To list1.ListCount - 1 'list1里面的内容
xlsheet.Cells(i + 1, 1) = list1.List(i) '转到excel
Next i
xlBook.Close SaveChanges:=True '以下三行关闭excel
xlApp.Quit
Set xlApp = Nothing
O(∩_∩)O~