package org.apache.poi.xssf.usermodel;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Iterator;
import java.util.TreeMap;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.util.CellReference;
+import org.apache.poi.util.Internal;
import org.apache.poi.util.POILogFactory;
import org.apache.poi.util.POILogger;
-import org.apache.poi.util.Internal;
import org.apache.poi.xssf.model.CalculationChain;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCell;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRow;
_row = row;
_sheet = sheet;
_cells = new TreeMap<Integer, XSSFCell>();
- for (CTCell c : row.getCArray()) {
+ for (CTCell c : row.getCList()) {
XSSFCell cell = new XSSFCell(this, c);
_cells.put(cell.getColumnIndex(), cell);
sheet.onReadCell(cell);
if(_row.sizeOfCArray() != _cells.size()) isOrdered = false;
else {
int i = 0;
- CTCell[] xcell = _row.getCArray();
for (XSSFCell cell : _cells.values()) {
CTCell c1 = cell.getCTCell();
- CTCell c2 = xcell[i++];
+ CTCell c2 = _row.getCArray(i++);
String r1 = c1.getR();
String r2 = c2.getR();
_rows = new TreeMap<Integer, XSSFRow>();
sharedFormulas = new HashMap<Integer, XSSFCell>();
arrayFormulas = new ArrayList<CellRangeAddress>();
- for (CTRow row : worksheet.getSheetData().getRowArray()) {
+ for (CTRow row : worksheet.getSheetData().getRowList()) {
XSSFRow r = new XSSFRow(row, this);
_rows.put(r.getRowNum(), r);
}
getPackagePart().getRelationshipsByType(XSSFRelation.SHEET_HYPERLINKS.getRelation());
// Turn each one into a XSSFHyperlink
- for(CTHyperlink hyperlink : worksheet.getHyperlinks().getHyperlinkArray()) {
+ for(CTHyperlink hyperlink : worksheet.getHyperlinks().getHyperlinkList()) {
PackageRelationship hyperRel = null;
if(hyperlink.getId() != null) {
hyperRel = hyperRels.getRelationshipByID(hyperlink.getId());
return new int[0];
}
- CTBreak[] brkArray = worksheet.getColBreaks().getBrkArray();
+ CTBreak[] brkArray = new CTBreak[worksheet.getColBreaks().getBrkList().size()];
+ worksheet.getColBreaks().getBrkList().toArray(brkArray);
+
int[] breaks = new int[brkArray.length];
for (int i = 0 ; i < brkArray.length ; i++) {
CTBreak brk = brkArray[i];
return new int[0];
}
- CTBreak[] brkArray = worksheet.getRowBreaks().getBrkArray();
+ CTBreak[] brkArray = new CTBreak[worksheet.getRowBreaks().getBrkList().size()];
+ worksheet.getRowBreaks().getBrkList().toArray(brkArray);
+
int[] breaks = new int[brkArray.length];
for (int i = 0 ; i < brkArray.length ; i++) {
CTBreak brk = brkArray[i];
private short getMaxOutlineLevelCols(){
CTCols ctCols=worksheet.getColsArray(0);
- CTCol[]colArray=ctCols.getColArray();
short outlineLevel=0;
- for(CTCol col: colArray){
+ for(CTCol col: ctCols.getColList()){
outlineLevel=col.getOutlineLevel()>outlineLevel? col.getOutlineLevel(): outlineLevel;
}
return outlineLevel;
* Removes a page break at the indicated column
*/
public void removeColumnBreak(int column) {
- CTBreak[] brkArray = getSheetTypeColumnBreaks().getBrkArray();
+ CTBreak[] brkArray = new CTBreak[getSheetTypeColumnBreaks().getBrkList().size()];
+ getSheetTypeColumnBreaks().getBrkList().toArray(brkArray);
+
for (int i = 0 ; i < brkArray.length ; i++) {
if (brkArray[i].getId() == column) {
getSheetTypeColumnBreaks().removeBrk(i);
*/
public void removeRowBreak(int row) {
CTPageBreak pgBreak = worksheet.isSetRowBreaks() ? worksheet.getRowBreaks() : worksheet.addNewRowBreaks();
- CTBreak[] brkArray = pgBreak.getBrkArray();
+ CTBreak[] brkArray = new CTBreak[pgBreak.getBrkList().size()];
+ pgBreak.getBrkList().toArray(brkArray);
for (int i = 0 ; i < brkArray.length ; i++) {
if (brkArray[i].getId() == row) {
pgBreak.removeBrk(i);
if(sheetComments != null){
//TODO shift Note's anchor in the associated /xl/drawing/vmlDrawings#.vml
CTCommentList lst = sheetComments.getCTComments().getCommentList();
- for (CTComment comment : lst.getCommentArray()) {
+ for (CTComment comment : lst.getCommentList()) {
CellReference ref = new CellReference(comment.getRef());
if(ref.getRow() == rownum){
ref = new CellReference(rownum + n, ref.getCol());
*/
public void setSelected(boolean value) {
CTSheetViews views = getSheetTypeSheetViews();
- for (CTSheetView view : views.getSheetViewArray()) {
+ for (CTSheetView view : views.getSheetViewList()) {
view.setTabSelected(value);
}
}
*/
private CTSheetView getDefaultSheetView() {
CTSheetViews views = getSheetTypeSheetViews();
- if (views == null || views.getSheetViewArray() == null || views.getSheetViewArray().length <= 0) {
+ if (views == null || views.getSheetViewList() == null || views.getSheetViewList().size() <= 0) {
return null;
}
- return views.getSheetViewArray(views.getSheetViewArray().length - 1);
+ return views.getSheetViewArray(views.getSheetViewList().size() - 1);
}
/**
protected void write(OutputStream out) throws IOException {
- if(worksheet.getColsArray().length == 1) {
+ if(worksheet.getColsList().size() == 1) {
CTCols col = worksheet.getColsArray(0);
- CTCol[] cols = col.getColArray();
- if(cols.length == 0) {
+ if(col.getColList().size() == 0) {
worksheet.setColsArray(null);
}
}
if(sheetData.sizeOfRowArray() != _rows.size()) isOrdered = false;
else {
int i = 0;
- CTRow[] xrow = sheetData.getRowArray();
for (XSSFRow row : _rows.values()) {
CTRow c1 = row.getCTRow();
- CTRow c2 = xrow[i++];
+ CTRow c2 = sheetData.getRowArray(i++);
if (c1.getR() != c2.getR()){
isOrdered = false;
break;
List<XSSFDataValidation> xssfValidations = new ArrayList<XSSFDataValidation>();
CTDataValidations dataValidations = this.worksheet.getDataValidations();
if( dataValidations!=null && dataValidations.getCount() > 0 ) {
- CTDataValidation[] dataValidationList = dataValidations.getDataValidationArray();
- for (CTDataValidation ctDataValidation : dataValidationList) {
+ for (CTDataValidation ctDataValidation : dataValidations.getDataValidationList()) {
CellRangeAddressList addressList = new CellRangeAddressList();
@SuppressWarnings("unchecked")
if( dataValidations==null ) {
dataValidations = worksheet.addNewDataValidations();
}
- int currentCount = dataValidations.getDataValidationArray().length;
+ int currentCount = dataValidations.getDataValidationList().size();
CTDataValidation newval = dataValidations.addNewDataValidation();
newval.set(xssfDataValidation.getCtDdataValidation());
dataValidations.setCount(currentCount + 1);
// Load individual sheets. The order of sheets is defined by the order of CTSheet elements in the workbook
sheets = new ArrayList<XSSFSheet>(shIdMap.size());
- for (CTSheet ctSheet : this.workbook.getSheets().getSheetArray()) {
+ for (CTSheet ctSheet : this.workbook.getSheets().getSheetList()) {
XSSFSheet sh = shIdMap.get(ctSheet.getId());
if(sh == null) {
logger.log(POILogger.WARN, "Sheet with name " + ctSheet.getName() + " and r:id " + ctSheet.getId()+ " was defined, but didn't exist in package, skipping");
// Process the named ranges
namedRanges = new ArrayList<XSSFName>();
if(workbook.isSetDefinedNames()) {
- for(CTDefinedName ctName : workbook.getDefinedNames().getDefinedNameArray()) {
+ for(CTDefinedName ctName : workbook.getDefinedNames().getDefinedNameList()) {
namedRanges.add(new XSSFName(ctName, this));
}
}
validateSheetIndex(index);
//activeTab (Active Sheet Index) Specifies an unsignedInt that contains the index to the active sheet in this book view.
- CTBookView[] arrayBook = workbook.getBookViews().getWorkbookViewArray();
+ CTBookView[] arrayBook = new CTBookView[workbook.getBookViews().getWorkbookViewList().size()];
+ workbook.getBookViews().getWorkbookViewList().toArray(arrayBook);
+
for (int i = 0; i < arrayBook.length; i++) {
workbook.getBookViews().getWorkbookViewArray(i).setActiveTab(index);
}
private void saveCalculationChain(){
if(calcChain != null){
- int count = calcChain.getCTCalcChain().getCArray().length;
+ int count = calcChain.getCTCalcChain().getCList().size();
if(count == 0){
removeRelation(calcChain);
calcChain = null;
* @return true if the sheet contains the name, false otherwise.
*/
private boolean containsSheet(String name, int excludeSheetIdx) {
- CTSheet[] ctSheetArray = workbook.getSheets().getSheetArray();
+ CTSheet[] ctSheetArray = new CTSheet[workbook.getSheets().getSheetList().size()];
+ workbook.getSheets().getSheetList().toArray(ctSheetArray);
+
for (int i = 0; i < ctSheetArray.length; i++) {
if (excludeSheetIdx != i && name.equalsIgnoreCase(ctSheetArray[i].getName()))
return true;