mirror of https://github.com/apache/poi.git
add test case for copying a cell with hyperlink
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1891778 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c7a5aed18e
commit
8c495d746e
|
@ -23,13 +23,9 @@ import static org.junit.jupiter.api.Assertions.assertSame;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.poi.common.usermodel.HyperlinkType;
|
||||
import org.apache.poi.ss.tests.usermodel.BaseTestXRow;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.CellCopyPolicy;
|
||||
import org.apache.poi.ss.usermodel.CellType;
|
||||
import org.apache.poi.ss.usermodel.RichTextString;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.xssf.XSSFITestDataProvider;
|
||||
import org.apache.poi.xssf.XSSFTestDataSamples;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -153,6 +149,27 @@ public final class TestXSSFRow extends BaseTestXRow {
|
|||
workbook.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCopyRowWithHyperlink() throws IOException {
|
||||
final XSSFWorkbook workbook = new XSSFWorkbook();
|
||||
final Sheet srcSheet = workbook.createSheet("src");
|
||||
final XSSFSheet destSheet = workbook.createSheet("dest");
|
||||
Row srcRow = srcSheet.createRow(0);
|
||||
Cell srcCell = srcRow.createCell(0);
|
||||
Hyperlink srcHyperlink = new XSSFHyperlink(HyperlinkType.URL);
|
||||
srcHyperlink.setAddress("https://poi.apache.org");
|
||||
srcCell.setHyperlink(srcHyperlink);
|
||||
|
||||
final XSSFRow destRow = destSheet.createRow(0);
|
||||
destRow.copyRowFrom(srcRow, new CellCopyPolicy());
|
||||
|
||||
Cell destCell = destRow.getCell(0);
|
||||
assertEquals(srcCell.getHyperlink().getAddress(), destCell.getHyperlink().getAddress(), "cell hyperlink addresses match");
|
||||
assertEquals(srcCell.getHyperlink().getType(), destCell.getHyperlink().getType(), "cell hyperlink types match");
|
||||
|
||||
workbook.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCopyRowOverwritesExistingRow() throws IOException {
|
||||
final XSSFWorkbook workbook = new XSSFWorkbook();
|
||||
|
|
Loading…
Reference in New Issue