Class SpreadsheetContent
In: gradesheet-rows.rb
Parent: Object

Class SpreadsheetContent is an exercise in reading OpenOffice documents from Ruby. It uses the Ruby Zip package to get the content of a spreadsheet. It makes the content available in the "content" attribute as a REXML:Document.

Methods

Attributes

content  [R]  content is a REXML::Document created in response to new SpreadsheetContent similar code to make the styles document available has been commented out in the source as it was not needed for this application.

Public Class methods

Application-specific initialization.

use initialize_content to get the content of the spreadsheet as a REXML:Document

Also set up the fixed_rows used in sturents_html() and the id_column used in students_row()

Public Instance methods

Take a (unexpanded) file name string as input. Sets the "content" attribute to the XML document from the content portion of the named file.

Raises exceptions errors from Zip::ZipFile.open and from Zip::ZipFile.get_input_stream and a Errno::ENOENT if the spreadsheet file is not found.

If the spreadsheet is being updated, you may want to call initialize_content periodically (with whatever locking is appropriate) to update the content.

students_html(row) takes a spreadsheet row number and returns a HTML table containing the text from visible columns for the passed row and from the fixed_rows. If the passed row is nil, then only processes the contents of the fixed_rows.

students_row(text) takes some text and returns the (first) row that contains the specified text in the id_column (or nil if no such row).

[Validate]