Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementing FODS format, see issue #39.
Needs to be tested. Merge branch 'issue-40-fods'
- Loading branch information
Showing
11 changed files
with
1,249 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,4 +119,4 @@ def elements | |
# end | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<office:document xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:presentation="urn:oasis:names:tc:opendocument:xmlns:presentation:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:css3t="http://www.w3.org/TR/css3-text/" office:version="1.2" office:mimetype="application/vnd.oasis.opendocument.spreadsheet"> | ||
<office:meta><meta:generator>Rspreadshhet gem by Gorn</meta:generator></office:meta> | ||
<office:automatic-styles /> | ||
<office:body> | ||
<office:spreadsheet /> | ||
</office:body> | ||
</office:document> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module Rspreadsheet | ||
VERSION = "0.4.9" | ||
VERSION = "0.5.0" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
require 'spec_helper' | ||
using ClassExtensions if RUBY_VERSION > '2.1' | ||
|
||
describe 'Rspreadsheet flat ODS format' do | ||
before do | ||
delete_tmpfile(@tmp_filename_fods = '/tmp/testfile.fods') # delete temp file before tests | ||
delete_tmpfile(@tmp_filename_ods = '/tmp/testfile.ods') | ||
end | ||
after do | ||
delete_tmpfile(@tmp_filename_fods) | ||
delete_tmpfile(@tmp_filename_ods) | ||
end | ||
|
||
it 'can open flat ods testfile and reads its content correctly' do | ||
book = Rspreadsheet.open($test_filename_fods, format: :fods ) | ||
s = book.worksheets(1) | ||
(1..10).each do |i| | ||
s[i,1].should === i | ||
end | ||
s[1,2].should === 'text' | ||
s[2,2].should === Date.new(2014,1,1) | ||
|
||
cell = s.cell(6,3) | ||
cell.format.bold.should == true | ||
cell = s.cell(6,4) | ||
cell.format.bold.should == false | ||
cell.format.italic.should == true | ||
cell = s.cell(6,5) | ||
cell.format.italic.should == false | ||
cell.format.color.should == '#ff3333' | ||
cell = s.cell(6,6) | ||
cell.format.color.should_not == '#ff3333' | ||
cell.format.background_color.should == '#6666ff' | ||
cell = s.cell(6,7) | ||
cell.format.font_size.should == '7pt' | ||
end | ||
|
||
it 'does not change when opened and saved again' do | ||
book = Rspreadsheet.new($test_filename_fods, format: :flat) # open test file | ||
book.save(@tmp_filename_fods) # and save it as temp file | ||
Rspreadsheet::Tools.xml_file_diff($test_filename_fods, @tmp_filename_fods).should be_nil | ||
end | ||
|
||
it 'can be converted to normal format with convert_format_to_normal', :pending do | ||
book = Rspreadsheet.open($test_filename_fods, format: :flat) | ||
book.convert_format_to_normal | ||
book.save_as(@tmp_filename_ods) | ||
Rspreadsheet::Tools.content_xml_diff($test_filename_fods, @tmp_filename_ods).should be_nil | ||
end | ||
|
||
it 'pick format automaticaaly' do | ||
book = Rspreadsheet.open($test_filename_fods) | ||
book.flat_format?.should == true | ||
book.save_as(@tmp_filename_fods) | ||
expect {book = Rspreadsheet.open(@tmp_filename_fods)}.not_to raise_error | ||
book.normal_format?.should == false | ||
|
||
book = Rspreadsheet.open($test_filename_ods) | ||
book.normal_format?.should == true | ||
book.save_as(@tmp_filename_ods) | ||
expect {book = Rspreadsheet.open(@tmp_filename_ods)}.not_to raise_error | ||
book.flat_format?.should == false | ||
end | ||
|
||
private | ||
def delete_tmpfile(afile) | ||
File.delete(afile) if File.exist?(afile) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
I think you forgot to remove this gem :)