From 058faf2581970fa18c314ad07f5658adeca32c69 Mon Sep 17 00:00:00 2001 From: Randy Morgan Date: Sun, 27 Nov 2011 22:08:55 +0900 Subject: update to README --- doc/Axlsx/Package.html | 274 +++++++++++++++++++++---------------------------- 1 file changed, 119 insertions(+), 155 deletions(-) (limited to 'doc/Axlsx/Package.html') diff --git a/doc/Axlsx/Package.html b/doc/Axlsx/Package.html index e1afdd68..df054277 100644 --- a/doc/Axlsx/Package.html +++ b/doc/Axlsx/Package.html @@ -94,11 +94,10 @@

Overview

-

-Package is responsible for managing all the bits and peices that Open + +

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. -

+serialization.

@@ -137,9 +136,8 @@ serialization. -

-Initializes your package. -

+
+

Initializes your package.

@@ -161,9 +159,8 @@ Initializes your package. -

-Accepts a ruport table for serialization to xlsx. -

+
+

Accepts a ruport table for serialization to xlsx.

@@ -185,9 +182,8 @@ Accepts a ruport table for serialization to xlsx. -

-Serialize your workbook to disk as an xlsx document. -

+
+

Serialize your workbook to disk as an xlsx document.

@@ -209,9 +205,8 @@ Serialize your workbook to disk as an xlsx document. -

-Validate all parts of the package against xsd schema. -

+
+

Validate all parts of the package against xsd schema.

@@ -233,9 +228,8 @@ Validate all parts of the package against xsd schema. -

-The workbook this package will serialize or validate. -

+
+

The workbook this package will serialize or validate.

@@ -277,9 +271,8 @@ The workbook this package will serialize or validate.

-

-Initializes your package -

+ +

Initializes your package

@@ -289,12 +282,10 @@ Initializes your package

Examples:

-

-Package.new :author => ‘you!’, :workbook => Workbook.new -

+

+

Package.new :author => ‘you!’, :workbook => Workbook.new

-
-
+

     
   

Parameters:

@@ -312,10 +303,9 @@ Package.new :author => ‘you!’, :workbook => Workbook.new — -

-A hash that you can use to specify the author and workbook for this -package. -

+
+

A hash that you can use to specify the author and workbook for this +package.

@@ -334,9 +324,8 @@ package. - —

-The author of the document -

+ —
+

The author of the document

@@ -369,9 +358,8 @@ The author of the document — -

-the object that the method was called on -

+
+

the object that the method was called on

@@ -394,13 +382,12 @@ the object that the method was called on
# File 'lib/axlsx/package.rb', line 12
 
-def initialize(options={})
-  @workbook = nil
-  @core, @app = Core.new, App.new
-  @core.creator = options[:author] || @core.creator
-  yield self if block_given?
-end
-
+def initialize(options={}) + @workbook = nil + @core, @app = Core.new, App.new + @core.creator = options[:author] || @core.creator + yield self if block_given? +end @@ -422,9 +409,8 @@ the object that the method was called on

-

-Accepts a ruport table for serialization to xlsx -

+ +

Accepts a ruport table for serialization to xlsx

@@ -443,9 +429,8 @@ Accepts a ruport table for serialization to xlsx — -

-a ruport Table object -

+
+

a ruport Table object

@@ -466,10 +451,9 @@ a ruport Table object
# File 'lib/axlsx/package.rb', line 21
 
-def ruport_table(table)
-  puts table
-end
-
+def ruport_table(table) + puts table +end @@ -487,17 +471,15 @@ a ruport Table object
Note: -

-A tremendous amount of effort has gone into ensuring that you cannot create +

+

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. -

+you cannot open the serialized file.

-

-Serialize your workbook to disk as an xlsx document. -

+ +

Serialize your workbook to disk as an xlsx document.

@@ -508,13 +490,12 @@ Serialize your workbook to disk as an xlsx document.

Examples:

-
# This is how easy it is to create a valid xlsx file. Of course you might want to add a sheet or two, and maybe some data, styles and charts.
-# Take a look at the README for an example of how to do it!
-f = File.open('test.xlsx', 'w')
-Package.new.serialize(f)
+      
# This is how easy it is to create a valid xlsx file. Of course you might want to add a sheet or two, and maybe some data, styles and charts.
+# Take a look at the README for an example of how to do it!
+f = File.open('test.xlsx', 'w')
+Package.new.serialize(f)
 
-# You will find a file called test.xlsx
-
+# You will find a file called test.xlsx

Parameters:

@@ -530,9 +511,8 @@ Serialize your workbook to disk as an xlsx document. — -

-The file you want to serialize your package to -

+
+

The file you want to serialize your package to

@@ -549,9 +529,8 @@ The file you want to serialize your package to — -

-Validate the package prior to serialization. -

+
+

Validate the package prior to serialization.

@@ -569,10 +548,9 @@ Validate the package prior to serialization. — -

-False if confirm_valid and validation errors exist. True if the package was -serialized -

+
+

False if confirm_valid and validation errors exist. True if the package was +serialized

@@ -614,25 +592,24 @@ serialized
# File 'lib/axlsx/package.rb', line 61
 
-def serialize(output, confirm_valid=false)
-  return false unless !confirm_valid || self.validate.empty?
-  p = parts
-  Zip::ZipOutputStream.open(output) do |zip|
-    p.each do |part| 
-      unless part[:doc].nil?
-        zip.put_next_entry(part[:entry]); 
-        zip.puts(part[:doc])
-      end
-      unless part[:path].nil?
-        zip.put_next_entry(part[:entry]); 
-        # binread for 1.9.3
-        zip.write IO.respond_to?(:binread) ? IO.binread(part[:path]) : IO.read(part[:path])
-      end          
-    end
-  end
-  true
-end
-
+def serialize(output, confirm_valid=false) + return false unless !confirm_valid || self.validate.empty? + p = parts + Zip::ZipOutputStream.open(output) do |zip| + p.each do |part| + unless part[:doc].nil? + zip.put_next_entry(part[:entry]); + zip.puts(part[:doc]) + end + unless part[:path].nil? + zip.put_next_entry(part[:entry]); + # binread for 1.9.3 + zip.write IO.respond_to?(:binread) ? IO.binread(part[:path]) : IO.read(part[:path]) + end + end + end + true +end @@ -650,25 +627,22 @@ serialized
Note: -

-This gem includes all schema from OfficeOpenXML-XMLSchema-Transitional.zip +

+

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 +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. -

+improved. Please report your errors to the gem author.

-

-Validate all parts of the package against xsd schema. -

+ +

Validate all parts of the package against xsd schema.

@@ -679,11 +653,10 @@ Validate all parts of the package against xsd schema.

Examples:

-
# The following will output any error messages found in serialization.
-p = Axlsx::Package.new
-# ... code to create sheets, charts, styles etc.
-p.validate.each { |error| puts error.message }
-
+
# The following will output any error messages found in serialization.
+p = Axlsx::Package.new
+# ... code to create sheets, charts, styles etc.
+p.validate.each { |error| puts error.message }
@@ -698,9 +671,8 @@ Validate all parts of the package against xsd schema. — -

-An array of all validation errors found. -

+
+

An array of all validation errors found.

@@ -729,12 +701,11 @@ An array of all validation errors found.
# File 'lib/axlsx/package.rb', line 95
 
-def validate
-  errors = []
-  parts.each { |part| errors.concat validate_single_doc(part[:schema], part[:doc]) unless part[:schema].nil? }
-  errors
-end
-
+def validate + errors = [] + parts.each { |part| errors.concat validate_single_doc(part[:schema], part[:doc]) unless part[:schema].nil? } + errors +end @@ -752,25 +723,22 @@ An array of all validation errors found.
Note: -

-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
-
+
+

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. -

+ +

The workbook this package will serialize or validate.

@@ -801,10 +769,9 @@ The workbook this package will serialize or validate. — -

-If no workbook instance has been assigned with this package a new Workbook -instance is returned. -

+
+

If no workbook instance has been assigned with this package a new Workbook +instance is returned.

@@ -821,9 +788,8 @@ instance is returned. -

-ArgumentError if workbook parameter is not a Workbook instance. -

+
+

ArgumentError if workbook parameter is not a Workbook instance.

@@ -845,12 +811,11 @@ ArgumentError if workbook parameter is not a Workbook instance.
# File 'lib/axlsx/package.rb', line 37
 
-def workbook
-  @workbook || @workbook = Workbook.new
-  yield @workbook if block_given?
-  @workbook
-end
-
+def workbook + @workbook || @workbook = Workbook.new + yield @workbook if block_given? + @workbook +end @@ -890,8 +855,7 @@ ArgumentError if workbook parameter is not a Workbook instance.
# File 'lib/axlsx/package.rb', line 44
 
-def workbook=(workbook) DataTypeValidator.validate "Package.workbook", Workbook, workbook; @workbook = workbook end
-
+def workbook=(workbook) DataTypeValidator.validate "Package.workbook", Workbook, workbook; @workbook = workbook; end @@ -902,9 +866,9 @@ ArgumentError if workbook parameter is not a Workbook instance.
-- cgit v1.2.3