From 4d16bfc43780e5d3f7368625700b583e3e98217a Mon Sep 17 00:00:00 2001 From: Randy Morgan Date: Sun, 27 Nov 2011 18:11:42 +0900 Subject: adding in row_style and col_style methods to worksheet and active record 'acts_as_axlsx' to provide to_xlsx. --- doc/Axlsx/Package.html | 378 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 248 insertions(+), 130 deletions(-) (limited to 'doc/Axlsx/Package.html') diff --git a/doc/Axlsx/Package.html b/doc/Axlsx/Package.html index 6ab5ca37..7b0a39c1 100644 --- a/doc/Axlsx/Package.html +++ b/doc/Axlsx/Package.html @@ -94,10 +94,11 @@

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

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

-
-

Initializes your package.

+

+Initializes your package. +

+
+ + + + +
  • + + + - (Object) ruport_table(table) + + + + + + + + + + + + +

    +Accepts a ruport table for serialization to xlsx. +

  • @@ -159,8 +185,9 @@ serialization.

    -
    -

    Serialize your workbook to disk as an xlsx document.

    +

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

    @@ -182,8 +209,9 @@ serialization.

    -
    -

    Validate all parts of the package against xsd schema.

    +

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

    @@ -205,8 +233,9 @@ serialization.

    -
    -

    The workbook this package will serialize or validate.

    +

    +The workbook this package will serialize or validate. +

    @@ -248,8 +277,9 @@ serialization.

    - -

    Initializes your package

    +

    +Initializes your package +

    @@ -259,10 +289,12 @@ serialization.

    Examples:

    -

    -

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

    +

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

    -
    
    +      
    +

    Parameters:

    @@ -280,9 +312,10 @@ serialization.

    — -
    -

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

    @@ -301,8 +334,9 @@ package.

    - —
    -

    The author of the document

    + —

    +The author of the document +

    @@ -335,8 +369,9 @@ package.

    — -
    -

    the object that the method was called on

    +

    +the object that the method was called on +

    @@ -359,12 +394,13 @@ package.

    # 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 + @@ -378,7 +414,69 @@ package.

    -

    +

    + + - (Object) ruport_table(table) + + + +

    +
    +

    +Accepts a ruport table for serialization to xlsx +

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + table + + + (Table) + + + + — +

      +a ruport Table object +

      +
      + +
    • + +
    + + +
    + + + + +
    +
    +
    +
    +21
    +22
    +23
    +
    +
    # File 'lib/axlsx/package.rb', line 21
    +
    +def ruport_table(table)
    +  puts table
    +end
    +
    +
    +
    + +
    +

    - (Boolean) serialize(output, confirm_valid = false) @@ -389,15 +487,17 @@ package.

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

    @@ -408,12 +508,13 @@ you cannot open the serialized file.

    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:

    @@ -429,8 +530,9 @@ you cannot open the serialized file.

    — -
    -

    The file you want to serialize your package to

    +

    +The file you want to serialize your package to +

    @@ -447,8 +549,9 @@ you cannot open the serialized file.

    — -
    -

    Validate the package prior to serialization.

    +

    +Validate the package prior to serialization. +

    @@ -466,9 +569,10 @@ you cannot open the serialized file.

    — -
    -

    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 +

    @@ -488,11 +592,6 @@ serialized

     
     
    -54
    -55
    -56
    -57
    -58
     59
     60
     61
    @@ -505,29 +604,35 @@ serialized

    68 69 70 -71
    +71 +72 +73 +74 +75 +76 -
    # File 'lib/axlsx/package.rb', line 54
    -
    -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
    +
    # File 'lib/axlsx/package.rb', line 59
    +
    +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
    +
    @@ -545,22 +650,25 @@ 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. +

    @@ -571,10 +679,11 @@ improved. Please report your errors to the gem author.

    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 }
    +
    @@ -589,8 +698,9 @@ improved. Please report your errors to the gem author.

    — -
    -

    An array of all validation errors found.

    +

    +An array of all validation errors found. +

    @@ -610,20 +720,21 @@ improved. Please report your errors to the gem author.

     
     
    -88
    -89
    -90
    -91
    -92
    +93 +94 +95 +96 +97 -
    # File 'lib/axlsx/package.rb', line 88
    -
    -def validate
    -  errors = []
    -  parts.each { |part| errors.concat validate_single_doc(part[:schema], part[:doc]) unless part[:schema].nil? }
    -  errors
    -end
    +
    # File 'lib/axlsx/package.rb', line 93
    +
    +def validate
    +  errors = []
    +  parts.each { |part| errors.concat validate_single_doc(part[:schema], part[:doc]) unless part[:schema].nil? }
    +  errors
    +end
    +
    @@ -641,22 +752,25 @@ improved. Please report your errors to the gem author.

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

    @@ -674,9 +788,10 @@ are a few examples:

    — -
    -

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

    @@ -693,8 +808,9 @@ instance is returned.

    -
    -

    ArgumentError if workbook parameter is not a Workbook instance.

    +

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

    @@ -707,16 +823,17 @@ instance is returned.

     
     
    -32
    -33
    -34
    +37 +38 +39 -
    # File 'lib/axlsx/package.rb', line 32
    +      
    # File 'lib/axlsx/package.rb', line 37
     
    -def workbook
    -  @workbook || @workbook = Workbook.new
    -end
    +def workbook + @workbook || @workbook = Workbook.new +end +
    @@ -751,12 +868,13 @@ instance is returned.

     
     
    -37
    +42 -
    # File 'lib/axlsx/package.rb', line 37
    +      
    # File 'lib/axlsx/package.rb', line 42
     
    -def workbook=(workbook) DataTypeValidator.validate "Package.workbook", Workbook, workbook; @workbook = workbook; end
    +def workbook=(workbook) DataTypeValidator.validate "Package.workbook", Workbook, workbook; @workbook = workbook end +
    @@ -767,9 +885,9 @@ instance is returned.

    -- cgit v1.2.3