The method getBytes() is undefined for the type Long

未始之末 2014-10-28 08:55:07
这种错误怎么解决,求大神指导
...全文
362 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
未始之末 2014-10-28
  • 打赏
  • 举报
回复
try { FileOutputStream fout = new FileOutputStream("E:/capt.xls"); wb.write(fout); fout.close(); } catch (Exception e) { e.printStackTrace(); } LOG.debug("exportExcel - end!"); return "E:/ca.xls"; } } }
shixitong 2014-10-28
  • 打赏
  • 举报
回复
hrts = new HSSFRichTextString(new String(entry.getCerEndtime().getBytes(), "gbk")); hrts = new HSSFRichTextString(new String(entry.getId().getBytes(), "gbk")); 看下这个entry.getCerEndtime()和entry.getId()的返回值是什么
未始之末 2014-10-28
  • 打赏
  • 举报
回复
int currentpage = 1; int cnt = 0; int totalpage = 0; int pagecnt = 1000; // 设置总页数 if (cnt % pagecnt == 0) { totalpage = cnt / pagecnt; } else { totalpage = cnt / pagecnt + 1; } // 设置报表的Sheet数 int sheetcnt = 1000; // 每个Sheet中记录的数目 int totalSheet; if (cnt % sheetcnt == 0) { totalSheet = cnt / sheetcnt; } else { totalSheet = cnt / sheetcnt + 1; } String[] ret = null; String path = ""; CaptPfxCert captPfxCert = CaptPfxCert.getCaptPfxCertInfo(); String basePath = captPfxCert.getCode(); if ((basePath == null) || ("".equals(basePath))) { basePath = "E:capt.xls"; } String inputPath = basePath; String outputPath = basePath; captPfxCert = CaptPfxCert.getCaptPfxCertInfo(); int baseLine = Integer.parseInt(captPfxCert.getCode()); FileInputStream filein = null; try { filein = new FileInputStream(inputPath + "/" + "capt.xls"); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } POIFSFileSystem fs = null; try { fs = new POIFSFileSystem(filein); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } HSSFWorkbook wb = null; try { wb = new HSSFWorkbook(fs); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } for (int i = 2; i <= totalSheet; i++) { wb.cloneSheet(0); } for (int i = 0; i < totalSheet; i++) { String sheetName = "证书查询" + "(" + totalSheet + "-" + (i + 1) + ")"; wb.setSheetName(i, sheetName); wb.getSheetAt(i).setSelected(false); } HSSFSheet sheet; HSSFCellStyle style; HSSFCellStyle styleLeft; int rowPos = 0; int pos; HSSFRow row; HSSFCell cell; HSSFRichTextString hrts; sheet = wb.getSheetAt(0); style = wb.createCellStyle(); style.setBorderTop(HSSFCellStyle.BORDER_THIN); style.setBorderLeft(HSSFCellStyle.BORDER_THIN); style.setBorderRight(HSSFCellStyle.BORDER_THIN); style.setTopBorderColor(HSSFColor.BLACK.index); style.setBorderBottom(HSSFCellStyle.BORDER_THIN); style.setAlignment(HSSFCellStyle.ALIGN_CENTER); styleLeft = wb.createCellStyle(); styleLeft.setBorderTop(HSSFCellStyle.BORDER_THIN); styleLeft.setBorderLeft(HSSFCellStyle.BORDER_THIN); styleLeft.setBorderRight(HSSFCellStyle.BORDER_THIN); styleLeft.setTopBorderColor(HSSFColor.BLACK.index); styleLeft.setBorderBottom(HSSFCellStyle.BORDER_THIN); styleLeft.setAlignment(HSSFCellStyle.ALIGN_LEFT); rowPos = 0; hrts = new HSSFRichTextString(); // 输出报表文件 int sheetIndex = 0; int recordcnt = 0; for (currentpage = 1; currentpage <= totalpage; currentpage++) { List list=new ArrayList(); for (int i = 0; i < list.size(); i++, rowPos++) { // 判断是否使用下一个Sheet if (recordcnt % sheetcnt == 0) { sheet = wb.getSheetAt(sheetIndex); style = wb.createCellStyle(); style.setBorderTop(HSSFCellStyle.BORDER_THIN); style.setBorderLeft(HSSFCellStyle.BORDER_THIN); style.setBorderRight(HSSFCellStyle.BORDER_THIN); style.setTopBorderColor(HSSFColor.BLACK.index); style.setBorderBottom(HSSFCellStyle.BORDER_THIN); style.setAlignment(HSSFCellStyle.ALIGN_CENTER); styleLeft = wb.createCellStyle(); styleLeft.setBorderTop(HSSFCellStyle.BORDER_THIN); styleLeft.setBorderLeft(HSSFCellStyle.BORDER_THIN); styleLeft.setBorderRight(HSSFCellStyle.BORDER_THIN); styleLeft.setTopBorderColor(HSSFColor.BLACK.index); styleLeft.setBorderBottom(HSSFCellStyle.BORDER_THIN); styleLeft.setAlignment(HSSFCellStyle.ALIGN_LEFT); rowPos = 0; hrts = new HSSFRichTextString(); sheetIndex++; } recordcnt++; CaptPfxCert entry = (CaptPfxCert) list.get(i); row = sheet.createRow((short) baseLine + rowPos); pos = 0; // NO cell = row.createCell((short) pos++); hrts = new HSSFRichTextString(new String(String.valueOf(recordcnt).getBytes(), "gbk")); cell.setCellStyle(style); // 主键 cell = row.createCell((short) pos++); if (entry.getId() == null) { hrts = new HSSFRichTextString(new String("".getBytes(), "gbk")); } else { hrts = new HSSFRichTextString(new String(entry.getId() .getBytes(), "gbk")); } cell.setCellStyle(styleLeft);
未始之末 2014-10-28
  • 打赏
  • 举报
回复
cell = row.createCell((short) pos++); if (entry.getCerEndtime() == null) { hrts = new HSSFRichTextString(new String("".getBytes(), "gbk")); } else { hrts = new HSSFRichTextString(new String(entry.getCerEndtime() .getBytes(), "gbk")); } cell.setCellStyle(styleLeft);
shixitong 2014-10-28
  • 打赏
  • 举报
回复
贴代码,从标题看,只能说使用不当的方法,Long 类型的没有这个方法getBytes()

50,541

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧