public class Spreadsheet
extends java.lang.Object
Constructor and Description |
---|
Spreadsheet(java.io.File excelFile)
Create a grade spreadsheet object mapping onto an existing
Excel spreadsheet file (xls or xslx format).
|
Modifier and Type | Method and Description |
---|---|
void |
breakOutByRow(java.lang.String sheetName,
java.io.File outputDir,
java.lang.String studentNameColumn,
java.lang.String totalsColumn)
Scans the given spreadsheet.
|
java.util.List<java.lang.String[]> |
evaluateSheet(java.lang.String sheetName,
boolean skipInvalidDataRows)
Fetch the contents (values only) of a sheet as a list (by rows) of
arrays (by column) of strings.
|
java.lang.String |
getCellValue(java.lang.String sheetName,
int rowNum,
int column)
Retrieve the value of a spreadsheet cell, expressed as a string.
|
void |
loadCSV(java.io.File csvFile,
java.lang.String sheetName)
Replace the contents of a sheet by the contents of a CSV file,
updating calculations elsewhere in the spreadsheet afterwards.
|
void |
storeCSV(java.io.File csvFile,
java.lang.String sheetName,
boolean skipInvalidDataRows)
Write the contents (values only) of a sheet by into a CSV file.
|
public Spreadsheet(java.io.File excelFile) throws org.apache.poi.EncryptedDocumentException, org.apache.poi.openxml4j.exceptions.InvalidFormatException, java.io.IOException
excelFile
- location of an Excel spreadsheet. Creates a
new spreadsheet if no such file exists.java.io.IOException
- if file cannot be readorg.apache.poi.openxml4j.exceptions.InvalidFormatException
- if file is a not a spreadsheetorg.apache.poi.EncryptedDocumentException
- if file is encrypted?public java.lang.String getCellValue(java.lang.String sheetName, int rowNum, int column)
sheetName
- name of the sheet from which to retrieverowNum
- index of the row from which to retrievecolumn
- index of the column from which to retrievepublic void loadCSV(java.io.File csvFile, java.lang.String sheetName) throws org.apache.poi.EncryptedDocumentException, org.apache.poi.openxml4j.exceptions.InvalidFormatException, java.io.IOException
csvFile
- a CSV file with one sheet's worth of spreadsheet data.sheetName
- the name of the sheet into which to place that data.
Normally this sheet should already exist (other wise there could
be no calculations upon it,java.io.IOException
org.apache.poi.openxml4j.exceptions.InvalidFormatException
org.apache.poi.EncryptedDocumentException
public void storeCSV(java.io.File csvFile, java.lang.String sheetName, boolean skipInvalidDataRows) throws org.apache.poi.EncryptedDocumentException, org.apache.poi.openxml4j.exceptions.InvalidFormatException, java.io.IOException
csvFile
- location of the desired CSV file.sheetName
- the name of the sheet from which to obtain the data.skipInvalidDataRows
- if true, omit any row containing a non-empty
value that is not a valid number or string.java.io.IOException
org.apache.poi.openxml4j.exceptions.InvalidFormatException
org.apache.poi.EncryptedDocumentException
public java.util.List<java.lang.String[]> evaluateSheet(java.lang.String sheetName, boolean skipInvalidDataRows) throws org.apache.poi.EncryptedDocumentException, org.apache.poi.openxml4j.exceptions.InvalidFormatException, java.io.IOException
sheetName
- the name of the sheet from which to obtain the data.skipInvalidDataRows
- if true, omit any row containing a non-empty
value that is not a valid number or string.java.io.IOException
org.apache.poi.openxml4j.exceptions.InvalidFormatException
org.apache.poi.EncryptedDocumentException
public void breakOutByRow(java.lang.String sheetName, java.io.File outputDir, java.lang.String studentNameColumn, java.lang.String totalsColumn) throws org.apache.poi.EncryptedDocumentException, org.apache.poi.openxml4j.exceptions.InvalidFormatException, java.io.IOException
sheetName
- which sheet of this spreadsheet to processoutputDir
- directory to contain the newly generated spreadsheetsstudentNameColumn
- column containing student identifierstotalsColumn
- column containing entry for the Total: rowjava.io.IOException
org.apache.poi.openxml4j.exceptions.InvalidFormatException
org.apache.poi.EncryptedDocumentException