📄 sheetreader.java
字号:
private Cell revertSharedFormula(BaseSharedFormulaRecord f)
{
int pos;
FormulaRecord fr;
pos = excelFile.getPos();
excelFile.setPos(f.getFilePos());
fr = new FormulaRecord(f.getRecord(), excelFile, formattingRecords, workbook, workbook, FormulaRecord.ignoreSharedFormula, sheet, workbookSettings);
Cell cell;
cell = fr.getFormula();
if(fr.getFormula().getType() == CellType.NUMBER_FORMULA)
{
NumberFormulaRecord nfr = (NumberFormulaRecord)fr.getFormula();
if(formattingRecords.isDate(fr.getXFIndex()))
cell = new DateFormulaRecord(nfr, formattingRecords, workbook, workbook, nineteenFour, sheet);
}
excelFile.setPos(pos);
return cell;
FormulaException e;
e;
logger.warn(CellReferenceHelper.getCellReference(fr.getColumn(), fr.getRow()) + " " + e.getMessage());
return null;
}
final int getNumRows()
{
return numRows;
}
final int getNumCols()
{
return numCols;
}
final Cell[][] getCells()
{
return cells;
}
final ArrayList getRowProperties()
{
return rowProperties;
}
final ArrayList getColumnInfosArray()
{
return columnInfosArray;
}
final ArrayList getHyperlinks()
{
return hyperlinks;
}
final ArrayList getCharts()
{
return charts;
}
final ArrayList getDrawings()
{
return drawings;
}
final DataValidation getDataValidation()
{
return dataValidation;
}
final Range[] getMergedCells()
{
return mergedCells;
}
final SheetSettings getSettings()
{
return settings;
}
final int[] getRowBreaks()
{
return rowBreaks;
}
final int[] getColumnBreaks()
{
return columnBreaks;
}
final WorkspaceInformationRecord getWorkspaceOptions()
{
return workspaceOptions;
}
final PLSRecord getPLS()
{
return plsRecord;
}
final ButtonPropertySetRecord getButtonPropertySet()
{
return buttonPropertySet;
}
private void addCellComment(int col, int row, String text, double width, double height)
{
Cell c = cells[row][col];
if(c == null)
{
logger.warn("Cell at " + CellReferenceHelper.getCellReference(col, row) + " not present - adding a blank");
MulBlankCell mbc = new MulBlankCell(row, col, 0, formattingRecords, sheet);
CellFeatures cf = new CellFeatures();
cf.setReadComment(text, width, height);
mbc.setCellFeatures(cf);
addCell(mbc);
return;
}
if(c instanceof CellFeaturesAccessor)
{
CellFeaturesAccessor cv = (CellFeaturesAccessor)c;
CellFeatures cf = cv.getCellFeatures();
if(cf == null)
{
cf = new CellFeatures();
cv.setCellFeatures(cf);
}
cf.setReadComment(text, width, height);
} else
{
logger.warn("Not able to add comment to cell type " + c.getClass().getName() + " at " + CellReferenceHelper.getCellReference(col, row));
}
}
private void addCellValidation(int col1, int row1, int col2, int row2, DataValiditySettingsRecord dvsr)
{
for(int row = row1; row <= row2; row++)
{
for(int col = col1; col <= col2; col++)
{
Cell c = null;
if(cells.length > row && cells[row].length > col)
c = cells[row][col];
if(c == null)
{
logger.warn("Cell at " + CellReferenceHelper.getCellReference(col, row) + " not present - adding a blank");
MulBlankCell mbc = new MulBlankCell(row, col, 0, formattingRecords, sheet);
CellFeatures cf = new CellFeatures();
cf.setValidationSettings(dvsr);
mbc.setCellFeatures(cf);
addCell(mbc);
return;
}
if(c instanceof CellFeaturesAccessor)
{
CellFeaturesAccessor cv = (CellFeaturesAccessor)c;
CellFeatures cf = cv.getCellFeatures();
if(cf == null)
{
cf = new CellFeatures();
cv.setCellFeatures(cf);
}
cf.setValidationSettings(dvsr);
} else
{
logger.warn("Not able to add comment to cell type " + c.getClass().getName() + " at " + CellReferenceHelper.getCellReference(col, row));
}
}
}
}
private void handleObjectRecord(ObjRecord objRecord, MsoDrawingRecord msoRecord, HashMap comments)
{
if(msoRecord == null)
{
logger.warn("Object record is not associated with a drawing record - ignoring");
return;
}
if(objRecord.getType() == ObjRecord.PICTURE)
{
if(drawingData == null)
drawingData = new DrawingData();
Drawing drawing = new Drawing(msoRecord, objRecord, drawingData, workbook.getDrawingGroup(), sheet);
drawings.add(drawing);
return;
}
if(objRecord.getType() == ObjRecord.EXCELNOTE)
{
if(drawingData == null)
drawingData = new DrawingData();
Comment comment = new Comment(msoRecord, objRecord, drawingData, workbook.getDrawingGroup(), workbookSettings);
Record r2 = excelFile.next();
if(r2.getType() == Type.MSODRAWING)
{
MsoDrawingRecord mso = new MsoDrawingRecord(r2);
comment.addMso(mso);
r2 = excelFile.next();
}
Assert.verify(r2.getType() == Type.TXO);
TextObjectRecord txo = new TextObjectRecord(r2);
comment.setTextObject(txo);
r2 = excelFile.next();
Assert.verify(r2.getType() == Type.CONTINUE);
ContinueRecord text = new ContinueRecord(r2);
comment.setText(text);
r2 = excelFile.next();
if(r2.getType() == Type.CONTINUE)
{
ContinueRecord formatting = new ContinueRecord(r2);
comment.setFormatting(formatting);
}
comments.put(new Integer(comment.getObjectId()), comment);
return;
}
if(objRecord.getType() == ObjRecord.COMBOBOX)
{
if(drawingData == null)
drawingData = new DrawingData();
ComboBox comboBox = new ComboBox(msoRecord, objRecord, drawingData, workbook.getDrawingGroup(), workbookSettings);
drawings.add(comboBox);
return;
}
if(objRecord.getType() == ObjRecord.BUTTON)
{
if(drawingData == null)
drawingData = new DrawingData();
Button button = new Button(msoRecord, objRecord, drawingData, workbook.getDrawingGroup(), workbookSettings);
Record r2 = excelFile.next();
if(r2.getType() == Type.MSODRAWING)
{
MsoDrawingRecord mso = new MsoDrawingRecord(r2);
button.addMso(mso);
r2 = excelFile.next();
}
Assert.verify(r2.getType() == Type.TXO);
TextObjectRecord txo = new TextObjectRecord(r2);
button.setTextObject(txo);
r2 = excelFile.next();
Assert.verify(r2.getType() == Type.CONTINUE);
ContinueRecord text = new ContinueRecord(r2);
button.setText(text);
r2 = excelFile.next();
if(r2.getType() == Type.CONTINUE)
{
ContinueRecord formatting = new ContinueRecord(r2);
button.setFormatting(formatting);
}
drawings.add(button);
return;
}
if(objRecord.getType() != ObjRecord.CHART)
{
logger.warn(objRecord.getType() + " on sheet \"" + sheet.getName() + "\" not supported - omitting");
if(drawingData == null)
drawingData = new DrawingData();
drawingData.addData(msoRecord.getData());
if(workbook.getDrawingGroup() != null)
workbook.getDrawingGroup().setDrawingsOmitted(msoRecord, objRecord);
return;
} else
{
return;
}
}
DrawingData getDrawingData()
{
return drawingData;
}
private void handleOutOfBoundsCells()
{
int resizedRows = numRows;
int resizedCols = numCols;
for(Iterator i = outOfBoundsCells.iterator(); i.hasNext();)
{
Cell cell = (Cell)i.next();
resizedRows = Math.max(resizedRows, cell.getRow() + 1);
resizedCols = Math.max(resizedCols, cell.getColumn() + 1);
}
logger.warn("Some cells exceeded the specified bounds. Resizing sheet dimensions from " + numCols + "x" + numRows + " to " + resizedCols + "x" + resizedRows);
if(resizedCols > numCols)
{
for(int r = 0; r < numRows; r++)
{
Cell newRow[] = new Cell[resizedCols];
System.arraycopy(cells[r], 0, newRow, 0, cells[r].length);
cells[r] = newRow;
}
}
if(resizedRows > numRows)
{
Cell newCells[][] = new Cell[resizedRows][];
System.arraycopy(cells, 0, newCells, 0, cells.length);
cells = newCells;
}
numRows = resizedRows;
numCols = resizedCols;
Cell cell;
for(Iterator i = outOfBoundsCells.iterator(); i.hasNext(); addCell(cell))
cell = (Cell)i.next();
outOfBoundsCells.clear();
}
static Class class$(String x0)
{
return Class.forName(x0);
ClassNotFoundException x1;
x1;
throw new NoClassDefFoundError(x1.getMessage());
}
static
{
logger = Logger.getLogger(class$jxl$read$biff$SheetReader != null ? class$jxl$read$biff$SheetReader : (class$jxl$read$biff$SheetReader = class$("jxl.read.biff.SheetReader")));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -