SXSSFSheet.addMergedRegion() 和 SXSSFSheet.addMergedRegionUnsafe() 之间的 Apache POI 区别?
Apache POI Difference between SXSSFSheet.addMergedRegion() & SXSSFSheet.addMergedRegionUnsafe()?
我正在使用 Apache POI 构建 excel 文件。由于数据可能非常大,我决定使用 SXSSFWorkbook 而不是 XSSFWorkbook。在应用程序 运行time 中,我可以看到 SXSSFSheet.addMergedRegionUnsafe() 运行 比 SXSSFSheet.addMergedRegion() 快,但我找不到任何与之相关的文档。所以我想知道使用 SXSSFSheet.addMergedRegionUnsafe() 是否有任何风险?
SXSSFSheet.addMergedRegionUnsafe
只需调用 XSSFSheet.addMergedRegionUnsafe. See source code of SXSSFSheet:
...
@Override
public int addMergedRegionUnsafe(CellRangeAddress region) {
return _sh.addMergedRegionUnsafe(region);
}
...
有_sh
是XSSFSheet
.
并且在 XSSFSheet.addMergedRegionUnsafe
中记录了行为:
Adds a merged region of cells (hence those cells form one). Skips
validation. It is possible to create overlapping merged regions or
create a merged region that intersects a multi-cell array formula with
this formula, which may result in a corrupt workbook. To check for
merged regions overlapping array formulas or other merged regions
after addMergedRegionUnsafe
has been called, call
validateMergedRegions()
, which runs in O(n^2) time.
所以 addMergedRegionUnsafe
运行得更快,因为它跳过了验证。因此,使用这个你的程序需要考虑不要创建重叠的合并区域,也不要创建与 multi-cell 数组公式与此公式相交的合并区域。否则结果工作簿会损坏。
来源 XSSFSheet.addMergedRegionUnsafe 的完整性。
我正在使用 Apache POI 构建 excel 文件。由于数据可能非常大,我决定使用 SXSSFWorkbook 而不是 XSSFWorkbook。在应用程序 运行time 中,我可以看到 SXSSFSheet.addMergedRegionUnsafe() 运行 比 SXSSFSheet.addMergedRegion() 快,但我找不到任何与之相关的文档。所以我想知道使用 SXSSFSheet.addMergedRegionUnsafe() 是否有任何风险?
SXSSFSheet.addMergedRegionUnsafe
只需调用 XSSFSheet.addMergedRegionUnsafe. See source code of SXSSFSheet:
...
@Override
public int addMergedRegionUnsafe(CellRangeAddress region) {
return _sh.addMergedRegionUnsafe(region);
}
...
有_sh
是XSSFSheet
.
并且在 XSSFSheet.addMergedRegionUnsafe
中记录了行为:
Adds a merged region of cells (hence those cells form one). Skips validation. It is possible to create overlapping merged regions or create a merged region that intersects a multi-cell array formula with this formula, which may result in a corrupt workbook. To check for merged regions overlapping array formulas or other merged regions after
addMergedRegionUnsafe
has been called, callvalidateMergedRegions()
, which runs in O(n^2) time.
所以 addMergedRegionUnsafe
运行得更快,因为它跳过了验证。因此,使用这个你的程序需要考虑不要创建重叠的合并区域,也不要创建与 multi-cell 数组公式与此公式相交的合并区域。否则结果工作簿会损坏。
来源 XSSFSheet.addMergedRegionUnsafe 的完整性。