简体   繁体   English

Apache POI CellReference 是否能够处理同一公式中的多个其他标签页?

[英]Is Apache POI CellReference able to handle multiple another tab sheets in the same formula?

I have a cell formula that references multiple sheets ('1 - Sheet':$P,$P:'1 - Sheet',$E:$E,'Another Calc'!$A10) When I try to instantiate a new CellReference object with my formula, Apache POI throws a error Bad sheet name quote escaping from parseSheetName method inside CellReference.我有一个引用多个工作表的单元格公式('1 - Sheet':$P,$P:'1 - Sheet',$E:$E,'Another Calc'!$A10)当我尝试实例化一个新的 CellReference object 使用我的公式,Apache POI 从 CellReference 中的parseSheetName方法中抛出错误Bad sheet name quote escaping。 This happens because the formula has multiple quotes and the method not handle this appropriately.发生这种情况是因为公式有多个引号并且方法没有正确处理这个问题。 Is there another way that CellReference can handle it or some kind of workaround to force CellReference handle appropriately? CellReference 是否有另一种方法可以处理它或某种变通方法来强制 CellReference 适当处理?

I've already done some research on but the all scenarios that I found were always with just a single reference in formula to another sheet and in this case the Apache POI works correctly.我已经做了一些研究,但我发现的所有场景总是只在公式中引用另一个工作表,在这种情况下,Apache POI 工作正常。

The comment from Alex Richter showed to me the problem was in how the formula was being passed to the CellReference constructor. Alex Richter评论向我表明问题在于如何将公式传递给CellReference构造函数。 I need change this, and Apache POI will work correctly.我需要更改它,Apache POI 将正常工作。

A CellReference is a reference to one cell, so this should work: CellReference是对一个单元格的引用,因此这应该有效:

var cellReference = new
    org.apache.poi.ss.util.CellReference(
        "'Another Calc'!$A10");

Alternatively, there is AreaReference to reference a cell range , so this should work too:或者,有AreaReference来引用单元格范围,所以这也应该有效:

var areaReference = new
    org.apache.poi.ss.util.AreaReference(
        "'1 - Sheet'!$P:$P", org.apache.poi.ss
            .SpreadsheetVersion.EXCEL2007);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM