jxl.write.biff
Class SheetWriter

java.lang.Object
  |
  +--jxl.write.biff.SheetWriter

final class SheetWriter
extends java.lang.Object

Contains the functionality necessary for writing out a sheet. Originally this was incorporated in WritableSheetImpl, but was moved out into a dedicated class in order to reduce the over bloated nature of that class


Field Summary
private  boolean chartOnly
          Flag indicates that this sheet contains just a chart, and nothing else
private  Chart[] charts
          The list of charts
private  java.util.TreeSet columnFormats
          The column format overrides
private  FooterRecord footer
          The page footer
private  HeaderRecord header
          The page header
private  java.util.ArrayList hyperlinks
          Array of hyperlinks
private  MergedCells mergedCells
          The list of merged ranges
private  int numCols
          The number of columns.
private  int numRows
          A number of rows.
private  File outputFile
          A handle to the output file which the binary data is written to
private  java.util.ArrayList rowBreaks
          Array of row page breaks
private  RowRecord[] rows
          The rows within this sheet
private  SheetSettings settings
          The settings for the sheet
private  WritableSheetImpl sheet
          A handle back to the writable sheet, in order for this class to invoke the get accessor methods
private  WorkbookSettings workbookSettings
          The settings for the workbook
private  WorkspaceInformationRecord workspaceOptions
          The workspace options
 
Constructor Summary
SheetWriter(File of, WritableSheetImpl wsi, WorkbookSettings ws)
          Creates a new SheetWriter instance.
 
Method Summary
(package private)  void checkMergedBorders()
          Check all the merged cells for borders.
(package private)  Chart[] getCharts()
           
private  Cell[] getColumn(int col)
          Get the cells in the column.
(package private)  FooterRecord getFooter()
          Gets the footer.
(package private)  HeaderRecord getHeader()
          Gets the header.
(package private)  WorkspaceInformationRecord getWorkspaceOptions()
           
(package private)  void setChartOnly()
          Sets a flag to indicate that this sheet contains a chart only
(package private)  void setCharts(Chart[] ch)
           
(package private)  void setDimensions(int rws, int cls)
          Sets the dimensions of this spreadsheet.
(package private)  void setFooter(FooterRecord fr)
           
(package private)  void setHeader(HeaderRecord hr)
           
(package private)  void setSettings(SheetSettings sr)
          Sets the sheet settings for this particular sheet.
(package private)  void setWorkspaceOptions(WorkspaceInformationRecord wo)
           
(package private)  void setWriteData(RowRecord[] rws, java.util.ArrayList rb, java.util.ArrayList hl, MergedCells mc, java.util.TreeSet cf)
          Sets the data necessary for writing out the sheet.
 void write()
          Writes out this sheet.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

outputFile

private File outputFile
A handle to the output file which the binary data is written to

rows

private RowRecord[] rows
The rows within this sheet

numRows

private int numRows
A number of rows. This is a count of the maximum row number + 1

numCols

private int numCols
The number of columns. This is a count of the maximum column number + 1

header

private HeaderRecord header
The page header

footer

private FooterRecord footer
The page footer

settings

private SheetSettings settings
The settings for the sheet

workbookSettings

private WorkbookSettings workbookSettings
The settings for the workbook

rowBreaks

private java.util.ArrayList rowBreaks
Array of row page breaks

hyperlinks

private java.util.ArrayList hyperlinks
Array of hyperlinks

mergedCells

private MergedCells mergedCells
The list of merged ranges

workspaceOptions

private WorkspaceInformationRecord workspaceOptions
The workspace options

columnFormats

private java.util.TreeSet columnFormats
The column format overrides

charts

private Chart[] charts
The list of charts

chartOnly

private boolean chartOnly
Flag indicates that this sheet contains just a chart, and nothing else

sheet

private WritableSheetImpl sheet
A handle back to the writable sheet, in order for this class to invoke the get accessor methods
Constructor Detail

SheetWriter

public SheetWriter(File of,
                   WritableSheetImpl wsi,
                   WorkbookSettings ws)
Creates a new SheetWriter instance.
Parameters:
of - the output file
Method Detail

write

public void write()
           throws java.io.IOException
Writes out this sheet. First writes out the standard sheet information then writes out each row in turn. Once all the rows have been written out, it retrospectively adjusts the offset references in the file
Throws:
java.io.IOException -  

setHeader

void setHeader(HeaderRecord hr)

getHeader

final HeaderRecord getHeader()
Gets the header. Called when copying sheets
Returns:
the page header

getFooter

final FooterRecord getFooter()
Gets the footer. Called when copying sheets
Returns:
the page footer

setFooter

void setFooter(FooterRecord fr)

setWriteData

void setWriteData(RowRecord[] rws,
                  java.util.ArrayList rb,
                  java.util.ArrayList hl,
                  MergedCells mc,
                  java.util.TreeSet cf)
Sets the data necessary for writing out the sheet. This method must be called immediately prior to writing
Parameters:
rws - the rows in the spreadsheet

setDimensions

void setDimensions(int rws,
                   int cls)
Sets the dimensions of this spreadsheet. This method must be called immediately prior to writing
Parameters:
rws - the number of rows
cls - the number of columns

setSettings

void setSettings(SheetSettings sr)
Sets the sheet settings for this particular sheet. Must be called immediately prior to writing
Parameters:
sr - the sheet settings

getWorkspaceOptions

WorkspaceInformationRecord getWorkspaceOptions()

setWorkspaceOptions

void setWorkspaceOptions(WorkspaceInformationRecord wo)

setCharts

void setCharts(Chart[] ch)

getCharts

Chart[] getCharts()

checkMergedBorders

void checkMergedBorders()
Check all the merged cells for borders. If the merge record has borders, then we need to rejig the cell formats to take account of this. This is called by the write method of the WritableWorkbookImpl, so that any new XFRecords that are created may be written out with the others

getColumn

private Cell[] getColumn(int col)
Get the cells in the column. Don't use the interface method getColumn for this as this will create loads of empty cells, and we could do without that overhead

setChartOnly

void setChartOnly()
Sets a flag to indicate that this sheet contains a chart only