jxl.write.biff
Class WritableWorkbookImpl

java.lang.Object
  |
  +--jxl.write.WritableWorkbook
        |
        +--jxl.write.biff.WritableWorkbookImpl
All Implemented Interfaces:
ExternalSheet

public class WritableWorkbookImpl
extends WritableWorkbook
implements ExternalSheet

A writable workbook


Field Summary
private  boolean closeStream
          Indicates whether or not the output stream should be closed.
private  ExternalSheetRecord externSheet
          The list of external sheets, used by cell references in formulas
private  Fonts fonts
          The list of fonts available within this workbook
private  FormattingRecords formatRecords
          The list of formats available within this workbook
private  MsoDrawingGroupRecord msoDrawingGroup
          The Mso Drawing Group
private  NameRecord[] names
          The name records
private  File outputFile
          The output file to write the workbook to
private  WorkbookSettings settings
          The settigs for the workbook
private  SharedStrings sharedStrings
          The shared strings used by this workbook
private  java.util.ArrayList sheets
          The list of sheets within this workbook
private  SupbookRecord[] supbooks
          The supbook records
private  boolean wbProtected
          The workbook protection flag
 
Fields inherited from class jxl.write.WritableWorkbook
ARIAL_10_PT, HYPERLINK_FONT, HYPERLINK_STYLE, NORMAL_STYLE
 
Constructor Summary
WritableWorkbookImpl(java.io.OutputStream os, boolean cs, WorkbookSettings ws)
          Constructor.
WritableWorkbookImpl(java.io.OutputStream os, Workbook w, boolean cs, WorkbookSettings ws)
          A pseudo copy constructor.
 
Method Summary
 void close()
          Closes this workbook, and frees makes any memory allocated available for garbage collection
 void copySheet(int s, java.lang.String name, int index)
          Copies the specified sheet and places it at the index specified by the parameter
 void copySheet(java.lang.String s, java.lang.String name, int index)
          Copies the specified sheet and places it at the index specified by the parameter
private  void copyWorkbook(Workbook w)
          Produces a writable copy of the workbook passed in by creating copies of each sheet in the specified workbook and adding them to its own record
 WritableSheet createSheet(java.lang.String name, int index)
          Creates a new sheet within the workbook, at the specified position.
 int getExternalSheetIndex(java.lang.String sheetName)
          Gets the external sheet index for the sheet name
 java.lang.String getExternalSheetName(int index)
          Gets the name of the external sheet specified by the index
 int getNumberOfSheets()
          Returns the number of sheets in this workbook
 WritableSheet getSheet(int index)
          Gets the specified sheet within this workbook
 WritableSheet getSheet(java.lang.String name)
          Gets the sheet with the specified name from within this workbook
 WritableSheet[] getSheets()
          Gets the sheets within this workbook.
 BOFRecord getWorkbookBof()
          Parsing of formulas is only supported for a subset of the available biff version, so we need to test to see if this version is acceptable
private  void rationalize()
          Rationalizes the cell formats, and then passes the resultant XF index mappings to each sheet in turn
 void removeSheet(int index)
          Removes a sheet from this workbook, the other sheets indices being altered accordingly.
 void setProtected(boolean prot)
          Indicates whether or not this workbook is protected
 void write()
          Writes out this sheet to the output file.
 
Methods inherited from class jxl.write.WritableWorkbook
copy
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

formatRecords

private FormattingRecords formatRecords
The list of formats available within this workbook

outputFile

private File outputFile
The output file to write the workbook to

sheets

private java.util.ArrayList sheets
The list of sheets within this workbook

fonts

private Fonts fonts
The list of fonts available within this workbook

externSheet

private ExternalSheetRecord externSheet
The list of external sheets, used by cell references in formulas

msoDrawingGroup

private MsoDrawingGroupRecord msoDrawingGroup
The Mso Drawing Group

supbooks

private SupbookRecord[] supbooks
The supbook records

names

private NameRecord[] names
The name records

sharedStrings

private SharedStrings sharedStrings
The shared strings used by this workbook

closeStream

private boolean closeStream
Indicates whether or not the output stream should be closed. This depends on whether this Workbook was created with an output stream, or a flat file (flat file closes the stream

wbProtected

private boolean wbProtected
The workbook protection flag

settings

private WorkbookSettings settings
The settigs for the workbook
Constructor Detail

WritableWorkbookImpl

public WritableWorkbookImpl(java.io.OutputStream os,
                            boolean cs,
                            WorkbookSettings ws)
                     throws java.io.IOException
Constructor. Writes the workbook direct to the existing output stream
Parameters:
os - the output stream
cs - TRUE if the workbook should close the output stream, FALSE
ws - the configuration for this workbook otherwise
Throws:
java.io.IOException -  

WritableWorkbookImpl

public WritableWorkbookImpl(java.io.OutputStream os,
                            Workbook w,
                            boolean cs,
                            WorkbookSettings ws)
                     throws java.io.IOException
A pseudo copy constructor. Takes the handles to the font and formatting records
Parameters:
w - the workbook to copy
os - the output stream to write the data to
cs - TRUE if the workbook should close the output stream, FALSE
ws - the configuration for this workbook
Throws:
java.io.IOException -  
Method Detail

getSheets

public WritableSheet[] getSheets()
Gets the sheets within this workbook. Use of this method for large worksheets can cause performance problems.
Overrides:
getSheets in class WritableWorkbook
Returns:
an array of the individual sheets

getSheet

public WritableSheet getSheet(int index)
Gets the specified sheet within this workbook
Overrides:
getSheet in class WritableWorkbook
Parameters:
index - the zero based index of the reQuired sheet
Returns:
The sheet specified by the index

getSheet

public WritableSheet getSheet(java.lang.String name)
Gets the sheet with the specified name from within this workbook
Overrides:
getSheet in class WritableWorkbook
Parameters:
name - the sheet name
Returns:
The sheet with the specified name, or null if it is not found

getNumberOfSheets

public int getNumberOfSheets()
Returns the number of sheets in this workbook
Overrides:
getNumberOfSheets in class WritableWorkbook
Returns:
the number of sheets in this workbook

close

public void close()
           throws java.io.IOException
Closes this workbook, and frees makes any memory allocated available for garbage collection
Overrides:
close in class WritableWorkbook
Throws:
java.io.IOException -  

createSheet

public WritableSheet createSheet(java.lang.String name,
                                 int index)
Creates a new sheet within the workbook, at the specified position. The new sheet is inserted at the specified position, or prepended/appended to the list of sheets if the index specified is somehow inappropriate
Overrides:
createSheet in class WritableWorkbook
Parameters:
name - the name of the new sheet
index - the index at which to add the sheet
Returns:
the created sheet

removeSheet

public void removeSheet(int index)
Removes a sheet from this workbook, the other sheets indices being altered accordingly. If the sheet referenced by the index does not exist, then no action is taken.
Overrides:
removeSheet in class WritableWorkbook
Parameters:
index - the index of the sheet to remove

write

public void write()
           throws java.io.IOException
Writes out this sheet to the output file. First it writes out the standard workbook information required by excel, before calling the write method on each sheet individually
Overrides:
write in class WritableWorkbook
Throws:
java.io.IOException -  

copyWorkbook

private void copyWorkbook(Workbook w)
Produces a writable copy of the workbook passed in by creating copies of each sheet in the specified workbook and adding them to its own record
Parameters:
w - the workbook to copy

copySheet

public void copySheet(int s,
                      java.lang.String name,
                      int index)
Copies the specified sheet and places it at the index specified by the parameter
Overrides:
copySheet in class WritableWorkbook
Parameters:
s - the index of the sheet to copy
name - the name of the new sheet
index - the position of the new sheet

copySheet

public void copySheet(java.lang.String s,
                      java.lang.String name,
                      int index)
Copies the specified sheet and places it at the index specified by the parameter
Overrides:
copySheet in class WritableWorkbook
Parameters:
s - the name of the sheet to copy
name - the name of the new sheet
index - the position of the new sheet

setProtected

public void setProtected(boolean prot)
Indicates whether or not this workbook is protected
Overrides:
setProtected in class WritableWorkbook
Parameters:
prot - protected flag

rationalize

private void rationalize()
Rationalizes the cell formats, and then passes the resultant XF index mappings to each sheet in turn

getExternalSheetName

public java.lang.String getExternalSheetName(int index)
Gets the name of the external sheet specified by the index
Specified by:
getExternalSheetName in interface ExternalSheet
Parameters:
index - the external sheet index
Returns:
the name of the external sheet

getWorkbookBof

public BOFRecord getWorkbookBof()
Parsing of formulas is only supported for a subset of the available biff version, so we need to test to see if this version is acceptable
Specified by:
getWorkbookBof in interface ExternalSheet
Returns:
the BOF record, which

getExternalSheetIndex

public int getExternalSheetIndex(java.lang.String sheetName)
Gets the external sheet index for the sheet name
Specified by:
getExternalSheetIndex in interface ExternalSheet
Parameters:
sheetName -  
Returns:
the sheet index or -1 if the sheet could not be found