Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
353 views
in Technique[技术] by (71.8m points)

java - 如何将超链接添加到工作表中的单元格,该单元格链接到同一工作簿中的工作表?(How to add hyperlink to a cell in the worksheet which links to worksheet in the same workbook?)

I am trying to validate xml and xsd.

(我正在尝试验证xml和xsd。)

For that I am creating an excel which has xml column that has xml name, xsd column that has xsd name, status column which has status of the validation and finally error column.

(为此,我正在创建一个具有xml列(具有xml名称), xsd列(具有xsd名称), status列(具有验证状态)和最后是error列的excel。)

If I get any errors during validation.

(验证期间是否出现任何错误。)

I am adding those errors to a sheet named as xml in the same workbook and creating hyperlink to that sheet in the error column.

(我将这些错误添加到同一工作簿中名为xml的工作表中,并在错误列中创建指向该工作表的超链接。)

检查我的excel表

if(String.valueOf(spreadSheetList.isValid).equalsIgnoreCase("false"))
{       
     cellSummary.setCellValue(spreadSheetList.getXmlName());
     Hyperlink link = createHelper.createHyperlink(Hyperlink.LINK_DOCUMENT);
     link.setAddress("'spreadSheetList.getXmlName()'!A1");
     cellSummary.setHyperlink((org.apache.poi.ss.usermodel.Hyperlink) link);
     cellSummary.setCellStyle(hlink_style);
}

I don't know why this block of code is not working.

(我不知道为什么这段代码不起作用。)

If I give sheet name directly link.setAddress("'acct_resv_request.xml'!A1") it was working fine.

(如果我直接给工作表名称link.setAddress("'acct_resv_request.xml'!A1")则工作正常。)

But I am giving error sheet name as my xml name.

(但是我给错误表名称作为我的xml名称。)

          for (XMLErrorObject spreadSheetList : listOfValidatedObject2) {

                if (!spreadSheetList.getExceptions().isEmpty() && spreadSheetList.getExceptions() != null) {
                    Sheet sheet1 = wb.createSheet(spreadSheetList.getXmlName());

                    // Specific cell number
                    int i1 = 0;

                    for (String ex : spreadSheetList.getExceptions()) {
                        Row row = sheet1.createRow(i1++);
                        Cell cell = row.createCell(0);
                        // putting value at specific position
                        cell.setCellValue(ex);
                    }

                }
            }

how to give the retrieved xml name link.setAddress("'spreadSheetList.getXmlName()'!A1") ?

(如何赋予检索到的XML名称link.setAddress("'spreadSheetList.getXmlName()'!A1") ?)

I don't want to give xml name directly there.

(我不想在那里直接给出xml名称。)

  ask by Hp29 translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...