You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TestXSSFRangeCopier.java 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * ====================================================================
  3. * Licensed to the Apache Software Foundation (ASF) under one or more
  4. * contributor license agreements. See the NOTICE file distributed with
  5. * this work for additional information regarding copyright ownership.
  6. * The ASF licenses this file to You under the Apache License, Version 2.0
  7. * (the "License"); you may not use this file except in compliance with
  8. * the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. * ====================================================================
  18. */
  19. package org.apache.poi.ss.usermodel;
  20. import static org.junit.Assert.assertEquals;
  21. import org.apache.poi.xssf.XSSFITestDataProvider;
  22. import org.apache.poi.xssf.XSSFTestDataSamples;
  23. import org.apache.poi.xssf.usermodel.XSSFRangeCopier;
  24. import org.apache.poi.xssf.usermodel.XSSFRow;
  25. import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  26. import org.junit.Before;
  27. import org.junit.Test;
  28. public class TestXSSFRangeCopier extends TestRangeCopier {
  29. public TestXSSFRangeCopier() {
  30. super();
  31. workbook = new XSSFWorkbook();
  32. testDataProvider = XSSFITestDataProvider.instance;
  33. }
  34. @Before
  35. public void init() {
  36. workbook = XSSFTestDataSamples.openSampleWorkbook("tile-range-test.xlsx");
  37. initSheets();
  38. rangeCopier = new XSSFRangeCopier(sheet1, sheet1);
  39. transSheetRangeCopier = new XSSFRangeCopier(sheet1, sheet2);
  40. }
  41. @Test // XSSF only. HSSF version wouldn't be so simple. And also this test is contained in following, more complex tests, so it's not really important.
  42. public void copyRow() {
  43. Row existingRow = sheet1.getRow(4);
  44. XSSFRow newRow = (XSSFRow)sheet1.getRow(5);
  45. CellCopyPolicy policy = new CellCopyPolicy();
  46. newRow.copyRowFrom(existingRow, policy);
  47. assertEquals("$C2+B$2", newRow.getCell(1).getCellFormula());
  48. }
  49. }