📄 sheetimpl.java
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi
// Source File Name: SheetImpl.java
package jxl.read.biff;
import common.Logger;
import java.util.ArrayList;
import java.util.Iterator;
import jxl.*;
import jxl.biff.*;
import jxl.biff.drawing.*;
import jxl.format.CellFormat;
// Referenced classes of package jxl.read.biff:
// ColumnInfoRecord, SheetReader, RowRecord, BiffException,
// WorkbookParser, File, BOFRecord, Record,
// SSTRecord, PLSRecord, ButtonPropertySetRecord
public class SheetImpl
implements Sheet
{
private static Logger logger;
private File excelFile;
private SSTRecord sharedStrings;
private BOFRecord sheetBof;
private BOFRecord workbookBof;
private FormattingRecords formattingRecords;
private String name;
private int numRows;
private int numCols;
private Cell cells[][];
private int startPosition;
private ColumnInfoRecord columnInfos[];
private RowRecord rowRecords[];
private ArrayList rowProperties;
private ArrayList columnInfosArray;
private ArrayList sharedFormulas;
private ArrayList hyperlinks;
private ArrayList charts;
private ArrayList drawings;
private ArrayList images;
private DataValidation dataValidation;
private Range mergedCells[];
private boolean columnInfosInitialized;
private boolean rowRecordsInitialized;
private boolean nineteenFour;
private WorkspaceInformationRecord workspaceOptions;
private boolean hidden;
private PLSRecord plsRecord;
private ButtonPropertySetRecord buttonPropertySet;
private SheetSettings settings;
private int rowBreaks[];
private int columnBreaks[];
private WorkbookParser workbook;
private WorkbookSettings workbookSettings;
static Class class$jxl$read$biff$SheetImpl; /* synthetic field */
SheetImpl(File f, SSTRecord sst, FormattingRecords fr, BOFRecord sb, BOFRecord wb, boolean nf, WorkbookParser wp)
throws BiffException
{
excelFile = f;
sharedStrings = sst;
formattingRecords = fr;
sheetBof = sb;
workbookBof = wb;
columnInfosArray = new ArrayList();
sharedFormulas = new ArrayList();
hyperlinks = new ArrayList();
rowProperties = new ArrayList(10);
columnInfosInitialized = false;
rowRecordsInitialized = false;
nineteenFour = nf;
workbook = wp;
workbookSettings = workbook.getSettings();
startPosition = f.getPos();
if(sheetBof.isChart())
startPosition -= sheetBof.getLength() + 4;
Record r = null;
int bofs = 1;
do
{
if(bofs < 1)
break;
r = f.next();
if(r.getCode() == Type.EOF.value)
bofs--;
if(r.getCode() == Type.BOF.value)
bofs++;
} while(true);
}
public Cell getCell(String loc)
{
return getCell(CellReferenceHelper.getColumn(loc), CellReferenceHelper.getRow(loc));
}
public Cell getCell(int column, int row)
{
if(cells == null)
readSheet();
Cell c = cells[row][column];
if(c == null)
{
c = new EmptyCell(column, row);
cells[row][column] = c;
}
return c;
}
public Cell findCell(String contents)
{
Cell cell = null;
boolean found = false;
for(int i = 0; i < getRows() && !found; i++)
{
Cell row[] = getRow(i);
for(int j = 0; j < row.length && !found; j++)
if(row[j].getContents().equals(contents))
{
cell = row[j];
found = true;
}
}
return cell;
}
public LabelCell findLabelCell(String contents)
{
LabelCell cell = null;
boolean found = false;
for(int i = 0; i < getRows() && !found; i++)
{
Cell row[] = getRow(i);
for(int j = 0; j < row.length && !found; j++)
if((row[j].getType() == CellType.LABEL || row[j].getType() == CellType.STRING_FORMULA) && row[j].getContents().equals(contents))
{
cell = (LabelCell)row[j];
found = true;
}
}
return cell;
}
public int getRows()
{
if(cells == null)
readSheet();
return numRows;
}
public int getColumns()
{
if(cells == null)
readSheet();
return numCols;
}
public Cell[] getRow(int row)
{
if(cells == null)
readSheet();
boolean found = false;
int col;
for(col = numCols - 1; col >= 0 && !found;)
if(cells[row][col] != null)
found = true;
else
col--;
Cell c[] = new Cell[col + 1];
for(int i = 0; i <= col; i++)
c[i] = getCell(i, row);
return c;
}
public Cell[] getColumn(int col)
{
if(cells == null)
readSheet();
boolean found = false;
int row;
for(row = numRows - 1; row >= 0 && !found;)
if(cells[row][col] != null)
found = true;
else
row--;
Cell c[] = new Cell[row + 1];
for(int i = 0; i <= row; i++)
c[i] = getCell(col, i);
return c;
}
public String getName()
{
return name;
}
final void setName(String s)
{
name = s;
}
public boolean isHidden()
{
return hidden;
}
public ColumnInfoRecord getColumnInfo(int col)
{
if(!columnInfosInitialized)
{
Iterator i = columnInfosArray.iterator();
ColumnInfoRecord cir = null;
do
{
if(!i.hasNext())
break;
cir = (ColumnInfoRecord)i.next();
int startcol = Math.max(0, cir.getStartColumn());
int endcol = Math.min(columnInfos.length - 1, cir.getEndColumn());
for(int c = startcol; c <= endcol; c++)
columnInfos[c] = cir;
if(endcol < startcol)
columnInfos[startcol] = cir;
} while(true);
columnInfosInitialized = true;
}
return col >= columnInfos.length ? null : columnInfos[col];
}
public ColumnInfoRecord[] getColumnInfos()
{
ColumnInfoRecord infos[] = new ColumnInfoRecord[columnInfosArray.size()];
for(int i = 0; i < columnInfosArray.size(); i++)
infos[i] = (ColumnInfoRecord)columnInfosArray.get(i);
return infos;
}
final void setHidden(boolean h)
{
hidden = h;
}
final void clear()
{
cells = (Cell[][])null;
mergedCells = null;
columnInfosArray.clear();
sharedFormulas.clear();
hyperlinks.clear();
columnInfosInitialized = false;
if(!workbookSettings.getGCDisabled())
System.gc();
}
final void readSheet()
{
if(!sheetBof.isWorksheet())
{
numRows = 0;
numCols = 0;
cells = new Cell[0][0];
}
SheetReader reader = new SheetReader(excelFile, sharedStrings, formattingRecords, sheetBof, workbookBof, nineteenFour, workbook, startPosition, this);
reader.read();
numRows = reader.getNumRows();
numCols = reader.getNumCols();
cells = reader.getCells();
rowProperties = reader.getRowProperties();
columnInfosArray = reader.getColumnInfosArray();
hyperlinks = reader.getHyperlinks();
charts = reader.getCharts();
drawings = reader.getDrawings();
dataValidation = reader.getDataValidation();
mergedCells = reader.getMergedCells();
settings = reader.getSettings();
settings.setHidden(hidden);
rowBreaks = reader.getRowBreaks();
columnBreaks = reader.getColumnBreaks();
workspaceOptions = reader.getWorkspaceOptions();
plsRecord = reader.getPLS();
buttonPropertySet = reader.getButtonPropertySet();
reader = null;
if(!workbookSettings.getGCDisabled())
System.gc();
if(columnInfosArray.size() > 0)
{
ColumnInfoRecord cir = (ColumnInfoRecord)columnInfosArray.get(columnInfosArray.size() - 1);
columnInfos = new ColumnInfoRecord[cir.getEndColumn() + 1];
} else
{
columnInfos = new ColumnInfoRecord[0];
}
}
public Hyperlink[] getHyperlinks()
{
Hyperlink hl[] = new Hyperlink[hyperlinks.size()];
for(int i = 0; i < hyperlinks.size(); i++)
hl[i] = (Hyperlink)hyperlinks.get(i);
return hl;
}
public Range[] getMergedCells()
{
if(mergedCells == null)
return new Range[0];
else
return mergedCells;
}
public RowRecord[] getRowProperties()
{
RowRecord rp[] = new RowRecord[rowProperties.size()];
for(int i = 0; i < rp.length; i++)
rp[i] = (RowRecord)rowProperties.get(i);
return rp;
}
public DataValidation getDataValidation()
{
return dataValidation;
}
RowRecord getRowInfo(int r)
{
if(!rowRecordsInitialized)
{
rowRecords = new RowRecord[getRows()];
Iterator i = rowProperties.iterator();
int rownum = 0;
RowRecord rr = null;
do
{
if(!i.hasNext())
break;
rr = (RowRecord)i.next();
rownum = rr.getRowNumber();
if(rownum < rowRecords.length)
rowRecords[rownum] = rr;
} while(true);
rowRecordsInitialized = true;
}
return r >= rowRecords.length ? null : rowRecords[r];
}
public final int[] getRowPageBreaks()
{
return rowBreaks;
}
public final int[] getColumnPageBreaks()
{
return columnBreaks;
}
public final Chart[] getCharts()
{
Chart ch[] = new Chart[charts.size()];
for(int i = 0; i < ch.length; i++)
ch[i] = (Chart)charts.get(i);
return ch;
}
public final DrawingGroupObject[] getDrawings()
{
DrawingGroupObject dr[] = new DrawingGroupObject[drawings.size()];
dr = (DrawingGroupObject[])drawings.toArray(dr);
return dr;
}
public boolean isProtected()
{
return settings.isProtected();
}
public WorkspaceInformationRecord getWorkspaceOptions()
{
return workspaceOptions;
}
public SheetSettings getSettings()
{
return settings;
}
WorkbookParser getWorkbook()
{
return workbook;
}
public CellFormat getColumnFormat(int col)
{
CellView cv = getColumnView(col);
return cv.getFormat();
}
public int getColumnWidth(int col)
{
return getColumnView(col).getSize() / 256;
}
public CellView getColumnView(int col)
{
ColumnInfoRecord cir = getColumnInfo(col);
CellView cv = new CellView();
if(cir != null)
{
cv.setDimension(cir.getWidth() / 256);
cv.setSize(cir.getWidth());
cv.setHidden(cir.getHidden());
cv.setFormat(formattingRecords.getXFRecord(cir.getXFIndex()));
} else
{
cv.setDimension(settings.getDefaultColumnWidth() / 256);
cv.setSize(settings.getDefaultColumnWidth());
}
return cv;
}
public int getRowHeight(int row)
{
return getRowView(row).getDimension();
}
public CellView getRowView(int row)
{
RowRecord rr = getRowInfo(row);
CellView cv = new CellView();
if(rr != null)
{
cv.setDimension(rr.getRowHeight());
cv.setSize(rr.getRowHeight());
cv.setHidden(rr.isCollapsed());
} else
{
cv.setDimension(settings.getDefaultRowHeight());
cv.setSize(settings.getDefaultRowHeight());
}
return cv;
}
public BOFRecord getSheetBof()
{
return sheetBof;
}
public BOFRecord getWorkbookBof()
{
return workbookBof;
}
public PLSRecord getPLS()
{
return plsRecord;
}
public ButtonPropertySetRecord getButtonPropertySet()
{
return buttonPropertySet;
}
public int getNumberOfImages()
{
if(images == null)
initializeImages();
return images.size();
}
public Image getDrawing(int i)
{
if(images == null)
initializeImages();
return (Image)images.get(i);
}
private void initializeImages()
{
if(images != null)
return;
images = new ArrayList();
DrawingGroupObject dgos[] = getDrawings();
for(int i = 0; i < dgos.length; i++)
if(dgos[i] instanceof Drawing)
images.add(dgos[i]);
}
public DrawingData getDrawingData()
{
SheetReader reader = new SheetReader(excelFile, sharedStrings, formattingRecords, sheetBof, workbookBof, nineteenFour, workbook, startPosition, this);
reader.read();
return reader.getDrawingData();
}
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$SheetImpl != null ? class$jxl$read$biff$SheetImpl : (class$jxl$read$biff$SheetImpl = class$("jxl.read.biff.SheetImpl")));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -