Package is responsible for managing all the bits and peices that Open Office XML requires to make a valid xlsx document including valdation and serialization.
Initializes your package
provides access to the app doc properties for this package see App
Creates the minimum content types for generating a valid xlsx document.
Appends override objects for drawings, charts, and sheets as they exist in your workbook to the default content types.
provides access to the core doc properties for the package see Core
Encrypt the package into a CFB using the password provided This is not ready yet
The parts of a package
Creates the relationships required for a valid xlsx document
A tremendous amount of effort has gone into ensuring that you cannot create invalid xlsx documents. confirm_valid should be used in the rare case that you cannot open the serialized file.
Serialize your workbook to disk as an xlsx document.
Serialize your workbook to a StringIO instance
Shortcut to specify that the workbook should use autowidth
Shortcut to determine if the workbook is configured to use shared strings
Shortcut to specify that the workbook should use shared strings
This gem includes all schema from OfficeOpenXML-XMLSchema-Transitional.zip and OpenPackagingConventions-XMLSchema.zip as per ECMA-376, Third edition. opc schema require an internet connection to import remote schema from dublin core for dc, dcterms and xml namespaces. Those remote schema are included in this gem, and the original files have been altered to refer to the local versions.
If by chance you are able to creat a package that does not validate it indicates that the internal validation is not robust enough and needs to be improved. Please report your errors to the gem author.
Validate all parts of the package against xsd schema.
Performs xsd validation for a signle document
As there are multiple ways to instantiate a workbook for the package, here are a few examples:
# assign directly during package instanciation wb = Package.new(:workbook => Workbook.new).workbook # get a fresh workbook automatically from the package wb = Pacakge.new().workbook # # set the workbook after creating the package wb = Package.new().workbook = Workbook.new
The workbook this package will serialize or validate.
Writes the package parts to a zip archive.
Generate a Entry for the given package part. The important part here is to explicitly set the timestamp for the zip entry: Serializing axlsx packages with identical contents should result in identical zip files – however, the timestamp of a zip entry defaults to the time of serialization and therefore the zip file contents would be different every time the package is serialized.
Note: Core#created also defaults to the current time – so to generate identical axlsx packages you have to set this explicitly, too (eg. with `Package.new(created_at: Time.local(2013, 1, 1))`).