- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 Aspose Cells Java 读取和验证行,但我以前从未使用过 ir,并且 de 文档不是很清楚,它甚至没有向您展示如何读取行。这是我到目前为止所做的:
public static void main(String[] args) {
String dataDir = "C:\\Users\\apoac22836\\Desktop\\";
Workbook wb = new Workbook(dataDir + "Example.xlsm");
Worksheet worksheet = wb.getWorksheets().get("BOM");
int column = 1;
for (int i = 0; i < 40; i++) {
Cell lastCell = worksheet.getCells().endCellInColumn((short) column);
for (int row = 0; row <= lastCell.getRow(); row++) {
Cell cell = worksheet.getCells().get(row, column);
System.out.println(cell.getStringValue());
}
column += 1;
System.out.println("------------------------------------------------");
}
}
我按列获取单元格的值。
最佳答案
好吧,如果您需要有效地枚举范围、行、单元格中的所有数据(非空值),您可以尝试使用 Range.iterator()、RowCollection.iterator() 和 Cells.iterator() 方法要获取特定范围、初始化行以及非空或初始化单元格的迭代器,请参阅以下示例代码供您引用:例如示例代码:
//Range Iterator.
Workbook book = new Workbook("sample.xlsx");
Worksheet sheet = book.getWorksheets().get(0);
Range range = sheet.getCells().getMaxDisplayRange();//You may also create your desired range (in the worksheet) using, e.g sheet.getCells().createRange("A1", "J11");
Iterator rangeIterator = range.iterator();
while(rangeIterator.hasNext())
{
Cell cell = (Cell)rangeIterator.next();
System.out.println(cell.getName() + " is not empty");
}
//Cells Iterator.
Workbook workbook = new Workbook("Book1.xls");
Worksheet sheet = workbook.getWorksheets().get(0);
Cells cells = sheet.getCells();
//Get the iterator from Cells collection
Iterator cellIterator = cells.iterator();
//Traverse cells in the collection
while (cellIterator.hasNext()) {
Cell cell = (Cell) cellIterator.next();
System.out.println(cell.getName() + " " + cell.getValue());
}
//Rows collection Iterator.
String filePath = "c:\\source.xlsx";
Workbook workbook = new Workbook(filePath);
Worksheet worksheet = workbook.getWorksheets().get(0);
RowCollection rows = worksheet.getCells().getRows();
Object obj = rows.iterator().next();
Iterator<Row> rowIterator = worksheet.getCells().getRows().iterator();
while(rowIterator.hasNext())
{
Row r = rowIterator.next();
Iterator<Cell> cellIterator = r.iterator();
while(cellIterator.hasNext())
{
Cell cell= cellIterator.next();
System.out.println(cell.getStringValue());
}
}
希望这会有所帮助。
我在 Aspose 担任支持开发人员/传播者。
关于java - 使用 Aspose JAva 读取和验证行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46120215/
我正在使用 Aspose 来处理 PDF 和 Word 文档。每次我要对文档做一些事情时,我一定要这样称呼: Aspose.Pdf.License pdfLicense = new Aspose.Pd
我们有一个报告项目,我们在其中使用 .NET 框架动态创建 Excel 报告。使用的不同组件是 System Namespace、Aspose.Cell 和 Aspose.Excel 我们有一份报告,
我的 excel 有数百万条记录(大约 1.1M),当我尝试使用 WorkSheet.Cells[row,cloumn] 逐个单元格读取时,速度非常慢。 相反,如果我使用 WorkSheet.Cell
在WEB项目中经常遇到excel文档在线预览的需求,基本的解决思路有以下几大类:excel文档转PDF、excel文档直接转html、后台读取excel数据返回给前端利用Excel效果的表格插件如
本文实例为大家分享了Aspose.Cells导出excel文件的方法,供大家参考,具体内容如下 ?
在 Aspose 和电子表格设备中,在将数据从数据库传输到 Excel 以及使用 C# 在 Excel 工作表中读取数据时,哪一个是最好的,或者还有其他更好的建议。这还应该包括通过 C# 应用条件格式
我们正在使用 Aspose PDF 并面临以下问题,这些问题有点令人讨厌: Aspose PDF 不会释放内存。我们已将 object 设置为 null 但它们不释放内存。结果 - 在我的 Web 服
我在设置包含“&”之类的网页标题文本时遇到了问题。 pdf中“&”后的文本消失了,可能是因为它是 Aspose 中的保留键。我的代码如下所示: PageSetup pageSetup = workb
我想生成第一页的缩略图。尝试生成以下页面,无法打印具有良好分辨率的图像,应该在缩放时显示具有良好分辨率的图像。即使我们可以选择打印前几列的缩略图也可以。请提出建议。 Workbook book = n
当我必须将 Word 文档转换为 png 图像时,我遇到了问题。 word文档里面有一个条形码(我已经附加了word进行转换)。使用 aspose 10.5,生成的 png 可以完美打印条形码,并且可
我想使用 C# 读取 pdf 文件中包含的 pdf417 条码的内容。我写了下面的代码: [...] // bind the pdf document Aspose.Pdf.Facades.PdfEx
我正在使用 aspose cells、word 来处理 csv 文件并将其复制到 Word 模板中,最后将其转换为 Pdf。在开发环境中它就像一个魅力,但是在生产环境中我有一些像 ö 这样的字母,它不
在使用 Aspose 将 docx 文件转换为 pdf 文件时,我得到了这个heap size 错误。这是代码 这个 docx 文件是 44Mb public void convertDoc(Stri
我正在为 java 使用 aspose-words-15.6.0 api。我想根据页码将页面方向更改为纵向或横向。 场景: 我有一个包含 3 页的 doc,我希望页面方向如下: 第一页:肖像。 第二页
我正在使用这些 jar 文件将 excel 和 power point 文件转换为 PDF aspose.slides-6.7.0.jar aspose.slides-6.7.0-jdk14.jar
最近遇到一个需求,要能够读取受密码保护的Excel内容,之前都是直接读取Excel中的数据,不需要做任何其他的处理. 当Excel双击的时候,需要输入密码,在使用Aspose.Cells 组件读取
我正在尝试为单元格的背景添加颜色,如下所示: style.BackgroundColor = Color.LightBlue; style.Pattern = BackgroundType.Solid
我正在尝试遍历数据集,使用Aspose.Words 邮件合并功能为每个项目创建一个页面。下面的代码循环遍历 Dataset - 并将一些值传递给 Mail-Merge Execute 函数。 var
我正在使用 aspose-slides-17.3-jdk16.jar for java。我想自定义 PPT 中幻灯片的页面设置。 任何帮助将不胜感激。 最佳答案 我观察到您使用 Aspose.Slid
我正在尝试遍历数据集,使用Aspose.Words 邮件合并功能为每个项目创建一个页面。下面的代码循环遍历 Dataset - 并将一些值传递给 Mail-Merge Execute 函数。 var
我是一名优秀的程序员,十分优秀!