2002-01-30 21:22:28 -05:00
|
|
|
/* ====================================================================
|
2006-12-22 14:18:16 -05:00
|
|
|
Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
contributor license agreements. See the NOTICE file distributed with
|
|
|
|
this work for additional information regarding copyright ownership.
|
|
|
|
The ASF licenses this file to You under the Apache License, Version 2.0
|
|
|
|
(the "License"); you may not use this file except in compliance with
|
|
|
|
the License. You may obtain a copy of the License at
|
2004-04-09 09:05:39 -04:00
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
==================================================================== */
|
2002-01-30 21:22:28 -05:00
|
|
|
|
|
|
|
package org.apache.poi.hssf.usermodel;
|
|
|
|
|
2008-04-06 23:02:03 -04:00
|
|
|
import java.util.GregorianCalendar;
|
|
|
|
import java.util.List;
|
|
|
|
|
2002-01-30 21:22:28 -05:00
|
|
|
import junit.framework.TestCase;
|
2008-04-06 23:02:03 -04:00
|
|
|
|
|
|
|
import org.apache.poi.hssf.HSSFTestDataSamples;
|
2009-12-21 20:08:33 -05:00
|
|
|
import org.apache.poi.hssf.model.InternalSheet;
|
2002-01-30 21:22:28 -05:00
|
|
|
import org.apache.poi.hssf.record.BOFRecord;
|
|
|
|
import org.apache.poi.hssf.record.EOFRecord;
|
|
|
|
|
|
|
|
/**
|
2002-02-10 23:23:11 -05:00
|
|
|
* @author Glen Stampoultzis (glens at apache.org)
|
2002-01-30 21:22:28 -05:00
|
|
|
*/
|
2008-04-06 23:02:03 -04:00
|
|
|
public final class TestReadWriteChart extends TestCase {
|
2002-01-30 21:22:28 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* In the presence of a chart we need to make sure BOF/EOF records still exist.
|
|
|
|
*/
|
2008-04-06 23:02:03 -04:00
|
|
|
public void testBOFandEOFRecords() {
|
|
|
|
HSSFWorkbook workbook = HSSFTestDataSamples.openSampleWorkbook("SimpleChart.xls");
|
2002-01-30 21:22:28 -05:00
|
|
|
HSSFSheet sheet = workbook.getSheetAt(0);
|
|
|
|
HSSFRow firstRow = sheet.getRow(0);
|
2008-08-25 18:41:08 -04:00
|
|
|
HSSFCell firstCell = firstRow.getCell(0);
|
2002-01-30 21:22:28 -05:00
|
|
|
|
2002-04-26 21:46:35 -04:00
|
|
|
//System.out.println("first assertion for date");
|
2002-01-30 21:22:28 -05:00
|
|
|
assertEquals(new GregorianCalendar(2000, 0, 1, 10, 51, 2).getTime(),
|
|
|
|
HSSFDateUtil
|
2007-12-04 12:06:57 -05:00
|
|
|
.getJavaDate(firstCell.getNumericCellValue(), false));
|
2008-08-25 18:41:08 -04:00
|
|
|
HSSFRow row = sheet.createRow(15);
|
|
|
|
HSSFCell cell = row.createCell(1);
|
2002-01-30 21:22:28 -05:00
|
|
|
|
|
|
|
cell.setCellValue(22);
|
2009-12-21 20:08:33 -05:00
|
|
|
InternalSheet newSheet = workbook.getSheetAt(0).getSheet();
|
2002-01-30 21:22:28 -05:00
|
|
|
List records = newSheet.getRecords();
|
|
|
|
|
|
|
|
assertTrue(records.get(0) instanceof BOFRecord);
|
|
|
|
assertTrue(records.get(records.size() - 1) instanceof EOFRecord);
|
|
|
|
}
|
|
|
|
}
|