如何在POI hssf中格式化列而不是单元格 [英] How to format a column instead of cell in POI hssf

查看:32
本文介绍了如何在POI hssf中格式化列而不是单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在打开包含数百/数千行数据的 Excel 文件时遇到问题,不同的单元格格式太多"

有关错误的更多信息
http://excelzoom.com/2009/09/the-mystery-of-excels-too-many-different-cell-formats/

所以我试图格式化列而不是单元格.我能弄清楚如何格式化列的唯一方法是格式化每个单独的单元格;通过实现下面列出的代码.我想格式化一列而不是一行.我有数百/数千行数据要格式化.任何建议将不胜感激.

谢谢,

HSSFCellStyle cellStyle = wb.createCellStyle();HSSFDataFormat dataFormat = wb.createDataFormat();cellStyle.setDataFormat(dataFormat.getFormat("0.00"));HSSFRow 行 = sheet.createRow(iRow);HSSFCell 单元格 = row.createCell((short)1);cell.setCellStyle(cellStyle);

解决方案

在这里找到答案

http://poi.apache.org/faq.html#faq-N1014B 转到部分

<块引用>

  1. 我在 POI 中创建工作簿时使用了样式,但 Excel 拒绝打开文件,抱怨样式太多".

山姆

I'm facing an issue when opening a excel file with hundreds/thousands of rows of data, "Too Many Different Cell Formats"

More info about the error
http://excelzoom.com/2009/09/the-mystery-of-excels-too-many-different-cell-formats/

So I'm trying to format a column not a cell. The only way I can figure out how to format a column is by formating each individual cell; by implementing the code listed below. I would like to format a column instead of a row. I have hundreds/thousands of rows of data to format. Any suggestions would be very much appreciated.

Thanks,

HSSFCellStyle cellStyle = wb.createCellStyle();
HSSFDataFormat dataFormat = wb.createDataFormat();
cellStyle.setDataFormat(dataFormat.getFormat("0.00"));

HSSFRow row = sheet.createRow(iRow);
HSSFCell cell = row.createCell((short)1);
cell.setCellStyle(cellStyle);

解决方案

Found the answer here

http://poi.apache.org/faq.html#faq-N1014B go to the section

  1. I am using styles when creating a workbook in POI, but Excel refuses to open the file, complaining about "Too Many Styles".

Sam

这篇关于如何在POI hssf中格式化列而不是单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆