import org.apache.poi.xssf.usermodel.extensions.XSSFCellFill;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlOptions;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorders;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellStyleXfs;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellXfs;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDxf;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDxfs;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFill;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFills;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFonts;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTNumFmt;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTNumFmts;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTStylesheet;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPatternType;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.StyleSheetDocument;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.*;
/**
// Work on the current one
// Need to do this, as we don't handle
// all the possible entries yet
- CTStylesheet styleSheet = doc.getStyleSheet();
+ CTStylesheet styleSheet = doc.getStyleSheet();
// Formats
CTNumFmts formats = CTNumFmts.Factory.newInstance();
int idx;
// Fonts
- CTFonts ctFonts = CTFonts.Factory.newInstance();
+ CTFonts ctFonts = styleSheet.getFonts();
+ if (ctFonts == null) {
+ ctFonts = CTFonts.Factory.newInstance();
+ }
ctFonts.setCount(fonts.size());
CTFont[] ctfnt = new CTFont[fonts.size()];
idx = 0;
styleSheet.setFonts(ctFonts);
// Fills
- CTFills ctFills = CTFills.Factory.newInstance();
+ CTFills ctFills = styleSheet.getFills();
+ if (ctFills == null) {
+ ctFills = CTFills.Factory.newInstance();
+ }
ctFills.setCount(fills.size());
CTFill[] ctf = new CTFill[fills.size()];
idx = 0;
styleSheet.setFills(ctFills);
// Borders
- CTBorders ctBorders = CTBorders.Factory.newInstance();
+ CTBorders ctBorders = styleSheet.getBorders();
+ if (ctBorders == null) {
+ ctBorders = CTBorders.Factory.newInstance();
+ }
ctBorders.setCount(borders.size());
CTBorder[] ctb = new CTBorder[borders.size()];
idx = 0;
// Xfs
if(xfs.size() > 0) {
- CTCellXfs ctXfs = CTCellXfs.Factory.newInstance();
+ CTCellXfs ctXfs = styleSheet.getCellXfs();
+ if (ctXfs == null) {
+ ctXfs = CTCellXfs.Factory.newInstance();
+ }
ctXfs.setCount(xfs.size());
ctXfs.setXfArray(
xfs.toArray(new CTXf[xfs.size()])
// Style xfs
if(styleXfs.size() > 0) {
- CTCellStyleXfs ctSXfs = CTCellStyleXfs.Factory.newInstance();
+ CTCellStyleXfs ctSXfs = styleSheet.getCellStyleXfs();
+ if (ctSXfs == null) {
+ ctSXfs = CTCellStyleXfs.Factory.newInstance();
+ }
ctSXfs.setCount(styleXfs.size());
ctSXfs.setXfArray(
styleXfs.toArray(new CTXf[styleXfs.size()])
// Style dxfs
if(dxfs.size() > 0) {
- CTDxfs ctDxfs = CTDxfs.Factory.newInstance();
+ CTDxfs ctDxfs = styleSheet.getDxfs();
+ if (ctDxfs == null) {
+ ctDxfs = CTDxfs.Factory.newInstance();
+ }
ctDxfs.setCount(dxfs.size());
ctDxfs.setDxfArray(dxfs.toArray(new CTDxf[dxfs.size()])
);
import org.apache.poi.ss.formula.eval.ErrorEval;
import org.apache.poi.ss.formula.eval.ValueEval;
import org.apache.poi.ss.formula.functions.Function;
-import org.apache.poi.ss.usermodel.BaseTestBugzillaIssues;
-import org.apache.poi.ss.usermodel.Cell;
-import org.apache.poi.ss.usermodel.CellStyle;
-import org.apache.poi.ss.usermodel.CellValue;
-import org.apache.poi.ss.usermodel.ClientAnchor;
-import org.apache.poi.ss.usermodel.Comment;
-import org.apache.poi.ss.usermodel.CreationHelper;
-import org.apache.poi.ss.usermodel.DataFormatter;
-import org.apache.poi.ss.usermodel.Drawing;
-import org.apache.poi.ss.usermodel.Font;
-import org.apache.poi.ss.usermodel.FormulaError;
-import org.apache.poi.ss.usermodel.FormulaEvaluator;
-import org.apache.poi.ss.usermodel.IndexedColors;
-import org.apache.poi.ss.usermodel.Name;
-import org.apache.poi.ss.usermodel.Row;
-import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.ss.usermodel.Workbook;
-import org.apache.poi.ss.usermodel.WorkbookFactory;
+import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.AreaReference;
import org.apache.poi.ss.util.CellReference;
import org.apache.poi.xssf.XSSFITestDataProvider;
* read the file despite the naughtyness
*/
public void test49020() throws Exception {
- XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("BrNotClosed.xlsx");
+ /*XSSFWorkbook wb =*/ XSSFTestDataSamples.openSampleWorkbook("BrNotClosed.xlsx");
}
/**
assertEquals(startingFonts+1, wb.getNumberOfFonts());
// Get two more, unchanged
- Font b = wb.createFont();
+ /*Font b =*/ wb.createFont();
assertEquals(startingFonts+2, wb.getNumberOfFonts());
- Font c = wb.createFont();
+ /*Font c =*/ wb.createFont();
assertEquals(startingFonts+3, wb.getNumberOfFonts());
}
}
/**
* Repeatedly writing the same file which has styles
- * TODO Currently failing
*/
- public void DISABLEDtest49940() throws Exception {
+ public void test49940() throws Exception {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("styles.xlsx");
assertEquals(3, wb.getNumberOfSheets());
assertEquals(10, wb.getStylesSource().getNumCellStyles());
* Setting repeating rows and columns shouldn't break
* any print settings that were there before
*/
- public void test49253() throws Exception {
+ @SuppressWarnings("deprecation")
+ public void test49253() throws Exception {
XSSFWorkbook wb1 = new XSSFWorkbook();
XSSFWorkbook wb2 = new XSSFWorkbook();
assertEquals(259.0, a1Value, 0.0);
// KY: SUM(B1: IZ1)
- double ky1Value =
+ /*double ky1Value =*/
evaluator.evaluate(workbook.getSheetAt(0).getRow(0).getCell(310)).getNumberValue();
// Assert