在 JAVA 中使用 JXL api 来自基于公式的单元格的垃圾内容
如果我使用公式,我在使用 JXL api 获取单元格内容时遇到问题 在 xls 表中。现在我在每个中使用公式 - IF($L10="","",+ROUND($L10*1.375,3)) 但是当单元格值为空时,当我调用 cell.getContents() 方法时,我收到垃圾字符,代码片段如下 - >>>
Workbook = Workbook.getWorkbook(p_sourceFile);
excelsheet = workbook.getSheet(0);
for (int row = 1; row < noOfRows; row++)
{
cell = excelsheet.getCell(col, row);
content = cell.getContents();
System.out.println("content-" + content); //Is giving me junk character ? when the cell value is blank.
...
如果有人能帮助我,那将是一个很大的帮助!
问候, 阿米特
I am facing a problem while getting contents of cell using JXL api, if I am using formula
in xls sheet. Right now I am using formula - IF($L10="","",+ROUND($L10*1.375,3)) in each
cell but when the cell value is blank i am getting junk charactes when i call cell.getContents() method, the code snip is as follows - >>
Workbook = Workbook.getWorkbook(p_sourceFile);
excelsheet = workbook.getSheet(0);
for (int row = 1; row < noOfRows; row++)
{
cell = excelsheet.getCell(col, row);
content = cell.getContents();
System.out.println("content-" + content); //Is giving me junk character ? when the cell value is blank.
...
It will be a great help if anyone can help me !!!
Regards,
Amit
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个:
来自 Cell.getContents() 的 JavaDocs:
数值公式的必要子接口是 NumberFormulaCell。如果您想获取字符串形式的公式,请调用 cell.getFormula()。
我不确定我是否真的在这里回答了你的问题。如果我不是,请您发布这些打印出来的垃圾字符好吗?
Try this:
From the JavaDocs for Cell.getContents():
The necessary subinterface for a numerical formula is NumberFormulaCell. If you want to get the formula as a String then call cell.getFormula().
I'm not sure if I'm really answering your question here or not. If I'm not, could you post these junk characters that get printed out, please?