rubyfromexcel 0.0.18 → 0.0.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. data/examples/ruby-versions/example-ruby/sheets/sheet1.rb +17 -0
  2. data/examples/ruby-versions/example-ruby/sheets/sheet2.rb +21 -0
  3. data/examples/ruby-versions/example-ruby/sheets/sheet3.rb +5 -0
  4. data/examples/ruby-versions/example-ruby/specs/sheet1_rspec.rb +8 -0
  5. data/examples/ruby-versions/example-ruby/specs/sheet2_rspec.rb +28 -0
  6. data/examples/ruby-versions/example-ruby/specs/sheet3_rspec.rb +8 -0
  7. data/examples/ruby-versions/example-ruby/spreadsheet.rb +9 -0
  8. data/examples/unzipped-sheets/example/[Content_Types].xml +2 -0
  9. data/examples/unzipped-sheets/example/docProps/app.xml +2 -0
  10. data/examples/unzipped-sheets/example/docProps/core.xml +2 -0
  11. data/examples/unzipped-sheets/example/xl/_rels/workbook.xml.rels +2 -0
  12. data/examples/unzipped-sheets/example/xl/calcChain.xml +2 -0
  13. data/examples/unzipped-sheets/example/xl/printerSettings/printerSettings1.bin +0 -0
  14. data/examples/unzipped-sheets/example/xl/sharedStrings.xml +2 -0
  15. data/examples/unzipped-sheets/example/xl/styles.xml +2 -0
  16. data/examples/unzipped-sheets/example/xl/theme/theme1.xml +2 -0
  17. data/examples/unzipped-sheets/example/xl/workbook.xml +2 -0
  18. data/examples/unzipped-sheets/example/xl/worksheets/_rels/sheet1.xml.rels +2 -0
  19. data/examples/unzipped-sheets/example/xl/worksheets/sheet1.xml +2 -0
  20. data/examples/unzipped-sheets/example/xl/worksheets/sheet2.xml +2 -0
  21. data/examples/unzipped-sheets/example/xl/worksheets/sheet3.xml +2 -0
  22. data/lib/excelfile/workbook.rb +2 -2
  23. data/lib/formulae/compile/formula_builder.rb +1 -1
  24. data/lib/formulae/run/reference.rb +1 -1
  25. data/lib/optimiser/dependency_builder.rb +2 -2
  26. data/spec/dependency_builder_spec.rb +2 -2
  27. data/spec/formula_builder_spec.rb +8 -8
  28. data/spec/workbook_spec.rb +2 -2
  29. metadata +29 -11
  30. data/examples/sheets/test1.xlsx +0 -0
  31. data/examples/sheets/test2.xlsx +0 -0
  32. data/examples/sheets/~$test1.xlsx +0 -0
@@ -0,0 +1,17 @@
1
+ # coding: utf-8
2
+ # 排放系数
3
+ class Sheet1 < Spreadsheet
4
+ def a3; "cells"; end
5
+ def b5; "emission coefficient"; end
6
+ def c5; "排放系数"; end
7
+ def b6; "coal"; end
8
+ def c6; "煤炭"; end
9
+ def d6; 2.7; end
10
+ def b7; "oil"; end
11
+ def c7; "石油"; end
12
+ def d7; 2.1; end
13
+ def b8; "gas"; end
14
+ def c8; "气"; end
15
+ def d8; 1.6; end
16
+ end
17
+
@@ -0,0 +1,21 @@
1
+ # coding: utf-8
2
+ # 计算
3
+ class Sheet2 < Spreadsheet
4
+ def b4; "coal"; end
5
+ def c4; "煤炭"; end
6
+ def d4; 100.0; end
7
+ def e4; @e4 ||= d4*sheet1.d6; end
8
+ def b5; "oil"; end
9
+ def c5; "石油"; end
10
+ def d5; 100.0; end
11
+ def e5; @e5 ||= d5*sheet1.d7; end
12
+ def b6; "gas"; end
13
+ def c6; "气"; end
14
+ def d6; 100.0; end
15
+ def e6; @e6 ||= d6*sheet1.d8; end
16
+ def b7; "sum"; end
17
+ def c7; "合计"; end
18
+ def d7; @d7 ||= sum(a('d4','d6')); end
19
+ def e7; @e7 ||= sum(a('e4','e6')); end
20
+ end
21
+
@@ -0,0 +1,5 @@
1
+ # coding: utf-8
2
+ # Sheet3
3
+ class Sheet3 < Spreadsheet
4
+ end
5
+
@@ -0,0 +1,8 @@
1
+ # coding: utf-8
2
+ require_relative '../spreadsheet'
3
+ # 排放系数
4
+ describe 'Sheet1' do
5
+ def sheet1; $spreadsheet ||= Spreadsheet.new; $spreadsheet.sheet1; end
6
+
7
+ end
8
+
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ require_relative '../spreadsheet'
3
+ # 计算
4
+ describe 'Sheet2' do
5
+ def sheet2; $spreadsheet ||= Spreadsheet.new; $spreadsheet.sheet2; end
6
+
7
+ it 'cell e4 should equal 270.0' do
8
+ sheet2.e4.should be_within(27.0).of(270.0)
9
+ end
10
+
11
+ it 'cell e5 should equal 210.0' do
12
+ sheet2.e5.should be_within(21.0).of(210.0)
13
+ end
14
+
15
+ it 'cell e6 should equal 160.0' do
16
+ sheet2.e6.should be_within(16.0).of(160.0)
17
+ end
18
+
19
+ it 'cell d7 should equal 300.0' do
20
+ sheet2.d7.should be_within(30.0).of(300.0)
21
+ end
22
+
23
+ it 'cell e7 should equal 640.0' do
24
+ sheet2.e7.should be_within(64.0).of(640.0)
25
+ end
26
+
27
+ end
28
+
@@ -0,0 +1,8 @@
1
+ # coding: utf-8
2
+ require_relative '../spreadsheet'
3
+ # Sheet3
4
+ describe 'Sheet3' do
5
+ def sheet3; $spreadsheet ||= Spreadsheet.new; $spreadsheet.sheet3; end
6
+
7
+ end
8
+
@@ -0,0 +1,9 @@
1
+ # coding: utf-8
2
+ require 'rubyfromexcel'
3
+
4
+ class Spreadsheet
5
+ include RubyFromExcel::ExcelFunctions
6
+
7
+ end
8
+
9
+ Dir[File.join(File.dirname(__FILE__),"sheets/","sheet*.rb")].each {|f| Spreadsheet.autoload(File.basename(f,".rb").capitalize,f)}
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="bin" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.printerSettings"/><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/xl/worksheets/sheet1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/><Override PartName="/xl/worksheets/sheet2.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/><Override PartName="/xl/worksheets/sheet3.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/><Override PartName="/xl/theme/theme1.xml" ContentType="application/vnd.openxmlformats-officedocument.theme+xml"/><Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/><Override PartName="/xl/sharedStrings.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml"/><Override PartName="/xl/calcChain.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.calcChain+xml"/><Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml"/><Override PartName="/docProps/app.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml"/></Types>
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"><Application>Microsoft Excel</Application><DocSecurity>0</DocSecurity><ScaleCrop>false</ScaleCrop><HeadingPairs><vt:vector size="4" baseType="variant"><vt:variant><vt:lpstr>工作表</vt:lpstr></vt:variant><vt:variant><vt:i4>3</vt:i4></vt:variant><vt:variant><vt:lpstr>命名范围</vt:lpstr></vt:variant><vt:variant><vt:i4>3</vt:i4></vt:variant></vt:vector></HeadingPairs><TitlesOfParts><vt:vector size="6" baseType="lpstr"><vt:lpstr>排放系数</vt:lpstr><vt:lpstr>计算</vt:lpstr><vt:lpstr>Sheet3</vt:lpstr><vt:lpstr>煤炭</vt:lpstr><vt:lpstr>气</vt:lpstr><vt:lpstr>石油</vt:lpstr></vt:vector></TitlesOfParts><Company></Company><LinksUpToDate>false</LinksUpToDate><SharedDoc>false</SharedDoc><HyperlinksChanged>false</HyperlinksChanged><AppVersion>14.0300</AppVersion></Properties>
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><dc:creator></dc:creator><cp:lastModifiedBy></cp:lastModifiedBy><dcterms:created xsi:type="dcterms:W3CDTF">2006-09-16T00:00:00Z</dcterms:created><dcterms:modified xsi:type="dcterms:W3CDTF">2012-02-23T03:22:22Z</dcterms:modified></cp:coreProperties>
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet3.xml"/><Relationship Id="rId7" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/calcChain" Target="calcChain.xml"/><Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet2.xml"/><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/><Relationship Id="rId6" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings" Target="sharedStrings.xml"/><Relationship Id="rId5" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/><Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" Target="theme/theme1.xml"/></Relationships>
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <calcChain xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><c r="D7" i="2" l="1"/><c r="E7" i="2"/><c r="E6" i="2"/><c r="E5" i="2"/><c r="E4" i="2"/></calcChain>
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="17" uniqueCount="14"><si><t>cells</t><phoneticPr fontId="1" type="noConversion"/></si><si><t>emission coefficient</t><phoneticPr fontId="1" type="noConversion"/></si><si><t>排放系数</t><phoneticPr fontId="1" type="noConversion"/></si><si><t>coal</t><phoneticPr fontId="1" type="noConversion"/></si><si><t>煤炭</t><phoneticPr fontId="1" type="noConversion"/></si><si><t>oil</t><phoneticPr fontId="1" type="noConversion"/></si><si><t>石油</t><phoneticPr fontId="1" type="noConversion"/></si><si><t>gas</t><phoneticPr fontId="1" type="noConversion"/></si><si><t>气</t><phoneticPr fontId="1" type="noConversion"/></si><si><t>coal</t><phoneticPr fontId="1" type="noConversion"/></si><si><t>煤炭</t><phoneticPr fontId="1" type="noConversion"/></si><si><t>石油</t><phoneticPr fontId="1" type="noConversion"/></si><si><t>sum</t><phoneticPr fontId="1" type="noConversion"/></si><si><t>合计</t><phoneticPr fontId="1" type="noConversion"/></si></sst>
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac"><fonts count="2" x14ac:knownFonts="1"><font><sz val="11"/><color theme="1"/><name val="宋体"/><family val="2"/><scheme val="minor"/></font><font><sz val="9"/><name val="宋体"/><family val="3"/><charset val="134"/><scheme val="minor"/></font></fonts><fills count="2"><fill><patternFill patternType="none"/></fill><fill><patternFill patternType="gray125"/></fill></fills><borders count="1"><border><left/><right/><top/><bottom/><diagonal/></border></borders><cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs><cellXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/></cellXfs><cellStyles count="1"><cellStyle name="常规" xfId="0" builtinId="0"/></cellStyles><dxfs count="0"/><tableStyles count="0" defaultTableStyle="TableStyleMedium2" defaultPivotStyle="PivotStyleMedium9"/><extLst><ext uri="{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}" xmlns:x14="http://schemas.microsoft.com/office/spreadsheetml/2009/9/main"><x14:slicerStyles defaultSlicerStyle="SlicerStyleLight1"/></ext></extLst></styleSheet>
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office 主题​​"><a:themeElements><a:clrScheme name="Office"><a:dk1><a:sysClr val="windowText" lastClr="000000"/></a:dk1><a:lt1><a:sysClr val="window" lastClr="FFFFFF"/></a:lt1><a:dk2><a:srgbClr val="1F497D"/></a:dk2><a:lt2><a:srgbClr val="EEECE1"/></a:lt2><a:accent1><a:srgbClr val="4F81BD"/></a:accent1><a:accent2><a:srgbClr val="C0504D"/></a:accent2><a:accent3><a:srgbClr val="9BBB59"/></a:accent3><a:accent4><a:srgbClr val="8064A2"/></a:accent4><a:accent5><a:srgbClr val="4BACC6"/></a:accent5><a:accent6><a:srgbClr val="F79646"/></a:accent6><a:hlink><a:srgbClr val="0000FF"/></a:hlink><a:folHlink><a:srgbClr val="800080"/></a:folHlink></a:clrScheme><a:fontScheme name="Office"><a:majorFont><a:latin typeface="Cambria"/><a:ea typeface=""/><a:cs typeface=""/><a:font script="Jpan" typeface="MS Pゴシック"/><a:font script="Hang" typeface="맑은 고딕"/><a:font script="Hans" typeface="宋体"/><a:font script="Hant" typeface="新細明體"/><a:font script="Arab" typeface="Times New Roman"/><a:font script="Hebr" typeface="Times New Roman"/><a:font script="Thai" typeface="Tahoma"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="MoolBoran"/><a:font script="Knda" typeface="Tunga"/><a:font script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font script="Tibt" typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Times New Roman"/><a:font script="Uigh" typeface="Microsoft Uighur"/><a:font script="Geor" typeface="Sylfaen"/></a:majorFont><a:minorFont><a:latin typeface="Calibri"/><a:ea typeface=""/><a:cs typeface=""/><a:font script="Jpan" typeface="MS Pゴシック"/><a:font script="Hang" typeface="맑은 고딕"/><a:font script="Hans" typeface="宋体"/><a:font script="Hant" typeface="新細明體"/><a:font script="Arab" typeface="Arial"/><a:font script="Hebr" typeface="Arial"/><a:font script="Thai" typeface="Tahoma"/><a:font script="Ethi" typeface="Nyala"/><a:font script="Beng" typeface="Vrinda"/><a:font script="Gujr" typeface="Shruti"/><a:font script="Khmr" typeface="DaunPenh"/><a:font script="Knda" typeface="Tunga"/><a:font script="Guru" typeface="Raavi"/><a:font script="Cans" typeface="Euphemia"/><a:font script="Cher" typeface="Plantagenet Cherokee"/><a:font script="Yiii" typeface="Microsoft Yi Baiti"/><a:font script="Tibt" typeface="Microsoft Himalaya"/><a:font script="Thaa" typeface="MV Boli"/><a:font script="Deva" typeface="Mangal"/><a:font script="Telu" typeface="Gautami"/><a:font script="Taml" typeface="Latha"/><a:font script="Syrc" typeface="Estrangelo Edessa"/><a:font script="Orya" typeface="Kalinga"/><a:font script="Mlym" typeface="Kartika"/><a:font script="Laoo" typeface="DokChampa"/><a:font script="Sinh" typeface="Iskoola Pota"/><a:font script="Mong" typeface="Mongolian Baiti"/><a:font script="Viet" typeface="Arial"/><a:font script="Uigh" typeface="Microsoft Uighur"/><a:font script="Geor" typeface="Sylfaen"/></a:minorFont></a:fontScheme><a:fmtScheme name="Office"><a:fillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="50000"/><a:satMod val="300000"/></a:schemeClr></a:gs><a:gs pos="35000"><a:schemeClr val="phClr"><a:tint val="37000"/><a:satMod val="300000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:tint val="15000"/><a:satMod val="350000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="16200000" scaled="1"/></a:gradFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:shade val="51000"/><a:satMod val="130000"/></a:schemeClr></a:gs><a:gs pos="80000"><a:schemeClr val="phClr"><a:shade val="93000"/><a:satMod val="130000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="94000"/><a:satMod val="135000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="16200000" scaled="0"/></a:gradFill></a:fillStyleLst><a:lnStyleLst><a:ln w="9525" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"><a:shade val="95000"/><a:satMod val="105000"/></a:schemeClr></a:solidFill><a:prstDash val="solid"/></a:ln><a:ln w="25400" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/></a:ln><a:ln w="38100" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/></a:ln></a:lnStyleLst><a:effectStyleLst><a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" dist="20000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="38000"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle><a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000"/></a:srgbClr></a:outerShdw></a:effectLst></a:effectStyle><a:effectStyle><a:effectLst><a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0"><a:srgbClr val="000000"><a:alpha val="35000"/></a:srgbClr></a:outerShdw></a:effectLst><a:scene3d><a:camera prst="orthographicFront"><a:rot lat="0" lon="0" rev="0"/></a:camera><a:lightRig rig="threePt" dir="t"><a:rot lat="0" lon="0" rev="1200000"/></a:lightRig></a:scene3d><a:sp3d><a:bevelT w="63500" h="25400"/></a:sp3d></a:effectStyle></a:effectStyleLst><a:bgFillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="40000"/><a:satMod val="350000"/></a:schemeClr></a:gs><a:gs pos="40000"><a:schemeClr val="phClr"><a:tint val="45000"/><a:shade val="99000"/><a:satMod val="350000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="20000"/><a:satMod val="255000"/></a:schemeClr></a:gs></a:gsLst><a:path path="circle"><a:fillToRect l="50000" t="-80000" r="50000" b="180000"/></a:path></a:gradFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="80000"/><a:satMod val="300000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="30000"/><a:satMod val="200000"/></a:schemeClr></a:gs></a:gsLst><a:path path="circle"><a:fillToRect l="50000" t="50000" r="50000" b="50000"/></a:path></a:gradFill></a:bgFillStyleLst></a:fmtScheme></a:themeElements><a:objectDefaults/><a:extraClrSchemeLst/></a:theme>
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><fileVersion appName="xl" lastEdited="5" lowestEdited="4" rupBuild="9302"/><workbookPr filterPrivacy="1" defaultThemeVersion="124226"/><bookViews><workbookView xWindow="240" yWindow="105" windowWidth="14805" windowHeight="8010" activeTab="1"/></bookViews><sheets><sheet name="排放系数" sheetId="1" r:id="rId1"/><sheet name="计算" sheetId="2" r:id="rId2"/><sheet name="Sheet3" sheetId="3" r:id="rId3"/></sheets><definedNames><definedName name="煤炭">排放系数!$D$6</definedName><definedName name="气">排放系数!$D$8</definedName><definedName name="石油">排放系数!$D$7</definedName></definedNames><calcPr calcId="145621"/></workbook>
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/printerSettings" Target="../printerSettings/printerSettings1.bin"/></Relationships>
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac"><dimension ref="A3:D8"/><sheetViews><sheetView workbookViewId="0"><selection activeCell="D6" sqref="D6"/></sheetView></sheetViews><sheetFormatPr defaultRowHeight="13.5" x14ac:dyDescent="0.15"/><cols><col min="2" max="2" width="22.75" bestFit="1" customWidth="1"/><col min="3" max="3" width="19.125" customWidth="1"/></cols><sheetData><row r="3" spans="1:4" x14ac:dyDescent="0.15"><c r="A3" t="s"><v>0</v></c></row><row r="5" spans="1:4" x14ac:dyDescent="0.15"><c r="B5" t="s"><v>1</v></c><c r="C5" t="s"><v>2</v></c></row><row r="6" spans="1:4" x14ac:dyDescent="0.15"><c r="B6" t="s"><v>3</v></c><c r="C6" t="s"><v>4</v></c><c r="D6"><v>2.7</v></c></row><row r="7" spans="1:4" x14ac:dyDescent="0.15"><c r="B7" t="s"><v>5</v></c><c r="C7" t="s"><v>6</v></c><c r="D7"><v>2.1</v></c></row><row r="8" spans="1:4" x14ac:dyDescent="0.15"><c r="B8" t="s"><v>7</v></c><c r="C8" t="s"><v>8</v></c><c r="D8"><v>1.6</v></c></row></sheetData><phoneticPr fontId="1" type="noConversion"/><pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/><pageSetup paperSize="9" orientation="portrait" r:id="rId1"/></worksheet>
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac"><dimension ref="B4:E7"/><sheetViews><sheetView tabSelected="1" workbookViewId="0"><selection activeCell="E4" sqref="E4"/></sheetView></sheetViews><sheetFormatPr defaultRowHeight="13.5" x14ac:dyDescent="0.15"/><sheetData><row r="4" spans="2:5" x14ac:dyDescent="0.15"><c r="B4" t="s"><v>9</v></c><c r="C4" t="s"><v>10</v></c><c r="D4"><v>100</v></c><c r="E4"><f>D4*煤炭</f><v>270</v></c></row><row r="5" spans="2:5" x14ac:dyDescent="0.15"><c r="B5" t="s"><v>5</v></c><c r="C5" t="s"><v>11</v></c><c r="D5"><v>100</v></c><c r="E5"><f>D5*石油</f><v>210</v></c></row><row r="6" spans="2:5" x14ac:dyDescent="0.15"><c r="B6" t="s"><v>7</v></c><c r="C6" t="s"><v>8</v></c><c r="D6"><v>100</v></c><c r="E6"><f>D6*气</f><v>160</v></c></row><row r="7" spans="2:5" x14ac:dyDescent="0.15"><c r="B7" t="s"><v>12</v></c><c r="C7" t="s"><v>13</v></c><c r="D7"><f>SUM(D4:D6)</f><v>300</v></c><c r="E7"><f>SUM(E4:E6)</f><v>640</v></c></row></sheetData><phoneticPr fontId="1" type="noConversion"/><pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/></worksheet>
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac"><dimension ref="A1"/><sheetViews><sheetView workbookViewId="0"/></sheetViews><sheetFormatPr defaultRowHeight="13.5" x14ac:dyDescent="0.15"/><sheetData/><phoneticPr fontId="1" type="noConversion"/><pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/></worksheet>
@@ -42,7 +42,7 @@ module RubyFromExcel
42
42
 
43
43
  def work_out_named_references_from(xml)
44
44
  xml.css('definedName').each do |defined_name_xml|
45
- reference_name = defined_name_xml['name'].gsub(/([a-z])([A-Z])/,'\1_\2').downcase.gsub(/[^a-z0-9_]/,'_')
45
+ reference_name = defined_name_xml['name'].downcase # .gsub(/[^a-z0-9_]/,'_')
46
46
  reference_value = defined_name_xml.content
47
47
  if reference_value.start_with?('[')
48
48
  puts "Sorry, #{reference_name} (#{reference_value}) has a link to an external workbook. Skipping."
@@ -97,7 +97,7 @@ module RubyFromExcel
97
97
  r.puts "@workbook_tables = #{Hash[Table.tables.sort]}"
98
98
  end
99
99
  named_references.each do |name,reference|
100
- r.put_simple_method name, reference
100
+ r.put_simple_method name.downcase.gsub(/[^\p{word}]/,'_'), reference
101
101
  end
102
102
  end
103
103
  end
@@ -1,6 +1,6 @@
1
1
  module TerminalNode
2
2
  def to_method_name
3
- self.gsub(/([a-z])([A-Z])/,'\1_\2').downcase.gsub(/[^a-z0-9_]/,'_')
3
+ self.gsub(/([a-z])([A-Z])/,'\1_\2').downcase.gsub(/[^\p{word}]/,'_')
4
4
  end
5
5
  end
6
6
 
@@ -9,7 +9,7 @@ module RubyFromExcel
9
9
 
10
10
  def self.column_to_integer(string)
11
11
  @column_to_integer_cache ||= {}
12
- return @column_to_integer_cache[string] ||= string.downcase.each_byte.to_a.reverse.each.with_index.inject(0) do |memo,byte_with_index,c|
12
+ return @column_to_integer_cache[string] ||= string.downcase.each_byte.to_a.reverse.each.with_index.inject(0) do |memo,byte_with_index|
13
13
  memo = memo + ((byte_with_index.first - 96) * (26**byte_with_index.last))
14
14
  end
15
15
  end
@@ -69,8 +69,8 @@ module RubyFromExcel
69
69
  end
70
70
 
71
71
  def reference_for_name(name)
72
- worksheet.named_references[name.to_method_name] ||
73
- workbook.named_references[name.to_method_name] ||
72
+ worksheet.named_references[name.downcase] ||
73
+ workbook.named_references[name.downcase] ||
74
74
  (raise Exception.new("#{name} in #{formula_cell} not found"))
75
75
  end
76
76
 
@@ -6,8 +6,8 @@ describe DependencyBuilder do
6
6
  SheetNames.instance.clear
7
7
  SheetNames.instance['Other Sheet'] = 'sheet2'
8
8
  @workbook = mock(:workbook, :named_references => {'named_cell' => 'sheet2.z10', 'named_cell2' => "sheet2.a('z10','ab10')"})
9
- @worksheet1 = mock(:worksheet, :to_s => 'sheet1', :workbook => @workbook, :named_references => {'named_cell' => 'sheet1.a1','this_year' => 'sheet1.a1'})
10
- @worksheet2 = mock(:worksheet, :to_s => 'sheet2', :workbook => @workbook, :named_references => {'year_matrix' => "sheet1.a('a20','a22')" })
9
+ @worksheet1 = mock(:worksheet, :to_s => 'sheet1', :workbook => @workbook, :named_references => {'named_cell' => 'sheet1.a1','this.year' => 'sheet1.a1'})
10
+ @worksheet2 = mock(:worksheet, :to_s => 'sheet2', :workbook => @workbook, :named_references => {'year.matrix' => "sheet1.a('a20','a22')" })
11
11
  @workbook.stub!(:worksheets => {'sheet1' => @worksheet1, 'sheet2' => @worksheet2 })
12
12
  @cell = mock(:cell,:worksheet => @worksheet1, :reference => Reference.new('c30',@worksheet1))
13
13
  @builder = DependencyBuilder.new(@cell)
@@ -82,19 +82,19 @@ describe FormulaBuilder do
82
82
  worksheet = mock(:worksheet)
83
83
  workbook = mock(:workbook)
84
84
  @builder.formula_cell = mock(:cell,:worksheet => worksheet)
85
- worksheet.should_receive(:named_references).and_return({"one_and2"=>'sheet1.a(\'a1\',\'f10\')'})
85
+ worksheet.should_receive(:named_references).and_return({"oneand2"=>'sheet1.a(\'a1\',\'f10\')'})
86
86
  ruby_for("SUM(OneAnd2)").should == "sum(sheet1.a('a1','f10'))"
87
87
  worksheet.should_receive(:named_references).and_return({})
88
88
  worksheet.should_receive(:workbook).and_return(workbook)
89
- workbook.should_receive(:named_references).and_return({"reference_one" => "sheet10.a1"})
89
+ workbook.should_receive(:named_references).and_return({"referenceone" => "sheet10.a1"})
90
90
  ruby_for("ReferenceOne").should == "sheet10.a1"
91
- worksheet.should_receive(:named_references).and_return({"one_and2"=>'sheet1.a(\'a1\',\'f10\')'})
91
+ worksheet.should_receive(:named_references).and_return({"oneand2"=>'sheet1.a(\'a1\',\'f10\')'})
92
92
  worksheet.should_receive(:workbook).and_return(workbook)
93
- workbook.should_receive(:named_references).and_return({"reference_one" => "sheet10.a1"})
93
+ workbook.should_receive(:named_references).and_return({"referenceone" => "sheet10.a1"})
94
94
  ruby_for("Reference.2").should == ":name"
95
- worksheet.should_receive(:named_references).and_return({"one_and2"=>'sheet1.a(\'a1\',\'f10\')'})
95
+ worksheet.should_receive(:named_references).and_return({"oneand2"=>'sheet1.a(\'a1\',\'f10\')'})
96
96
  worksheet.should_receive(:workbook).and_return(workbook)
97
- workbook.should_receive(:named_references).and_return({"reference_one" => "sheet10.a1","ef_natural_gas_n2o"=> "sheet10.a1"})
97
+ workbook.should_receive(:named_references).and_return({"referenceone" => "sheet10.a1","ef.naturalgas.n2o"=> "sheet10.a1"})
98
98
  ruby_for("-($AG70+$X70)*EF.NaturalGas.N2O").should == "-(ag70+x70)*sheet10.a1"
99
99
  end
100
100
 
@@ -116,7 +116,7 @@ describe FormulaBuilder do
116
116
 
117
117
  it "should convert table names inside indirects" do
118
118
  workbook = mock(:workbook, :named_references => {'named_cell' => 'sheet2.z10', 'named_cell2' => "sheet2.a('z10','ab10')"})
119
- worksheet1 = mock(:worksheet,:name => "sheet1", :to_s => 'sheet1', :workbook => workbook, :named_references => {'named_cell' => 'sheet1.a1','this_year' => 'sheet1.a1'})
119
+ worksheet1 = mock(:worksheet,:name => "sheet1", :to_s => 'sheet1', :workbook => workbook, :named_references => {'named_cell' => 'sheet1.a1','this.year' => 'sheet1.a1'})
120
120
  worksheet2 = mock(:worksheet,:name => "sheet2", :to_s => 'sheet2', :workbook => workbook, :named_references => {})
121
121
  workbook.stub!(:worksheets => {'sheet1' => worksheet1, 'sheet2' => worksheet2 })
122
122
  worksheet1.should_receive(:cell).with('c102').twice.and_return(mock(:cell,:value_for_including => 'XVI.a',:can_be_replaced_with_value? => true))
@@ -212,7 +212,7 @@ describe FormulaBuilder do
212
212
  worksheet.should_receive(:cell).with('a1').and_return(cell)
213
213
  ruby_for('INDIRECT(sheet100!A1&"!A1")').should == "sheet100.a1"
214
214
 
215
- worksheet.should_receive(:named_references).and_return({"this_year" => 'sheet1.a1'})
215
+ worksheet.should_receive(:named_references).and_return({"this.year" => 'sheet1.a1'})
216
216
  worksheet.should_receive(:workbook).and_return(workbook)
217
217
  workbook.should_receive(:worksheets).and_return({'sheet1' => worksheet})
218
218
  worksheet.should_receive(:cell).with('a1').and_return(nil)
@@ -103,9 +103,9 @@ class Spreadsheet
103
103
  @workbook_tables = {}
104
104
  end
105
105
 
106
- def one_and2; sheet2.a('a2','a3'); end
106
+ def oneand2; sheet2.a('a2','a3'); end
107
107
  def reference_2; sheet2.a3; end
108
- def reference_one; sheet2.a2; end
108
+ def referenceone; sheet2.a2; end
109
109
  end
110
110
 
111
111
  Dir[File.join(File.dirname(__FILE__),"sheets/","sheet*.rb")].each {|f| Spreadsheet.autoload(File.basename(f,".rb").capitalize,f)}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyfromexcel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.18
4
+ version: 0.0.19
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-16 00:00:00.000000000 Z
12
+ date: 2012-02-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
16
- requirement: &70132958509220 !ruby/object:Gem::Requirement
16
+ requirement: &70204693814680 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 1.4.1
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70132958509220
24
+ version_requirements: *70204693814680
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rubyscriptwriter
27
- requirement: &70132958508720 !ruby/object:Gem::Requirement
27
+ requirement: &70204693814180 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.0.1
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70132958508720
35
+ version_requirements: *70204693814180
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rubypeg
38
- requirement: &70132958508260 !ruby/object:Gem::Requirement
38
+ requirement: &70204693813720 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: 0.0.2
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70132958508260
46
+ version_requirements: *70204693813720
47
47
  description:
48
48
  email: ruby-from-excel@greenonblack.com
49
49
  executables:
@@ -131,6 +131,13 @@ files:
131
131
  - examples/ruby-versions/complex-test-ruby/specs/sheet1_rspec.rb
132
132
  - examples/ruby-versions/complex-test-ruby/specs/sheet2_rspec.rb
133
133
  - examples/ruby-versions/complex-test-ruby/spreadsheet.rb
134
+ - examples/ruby-versions/example-ruby/sheets/sheet1.rb
135
+ - examples/ruby-versions/example-ruby/sheets/sheet2.rb
136
+ - examples/ruby-versions/example-ruby/sheets/sheet3.rb
137
+ - examples/ruby-versions/example-ruby/specs/sheet1_rspec.rb
138
+ - examples/ruby-versions/example-ruby/specs/sheet2_rspec.rb
139
+ - examples/ruby-versions/example-ruby/specs/sheet3_rspec.rb
140
+ - examples/ruby-versions/example-ruby/spreadsheet.rb
134
141
  - examples/ruby-versions/namedReferenceTest-ruby/sheets/sheet1.rb
135
142
  - examples/ruby-versions/namedReferenceTest-ruby/sheets/sheet2.rb
136
143
  - examples/ruby-versions/namedReferenceTest-ruby/specs/sheet1_rspec.rb
@@ -174,10 +181,7 @@ files:
174
181
  - examples/sheets/pruning.xlsx
175
182
  - examples/sheets/sharedFormulaTest.xlsx
176
183
  - examples/sheets/table-test.xlsx
177
- - examples/sheets/test1.xlsx
178
- - examples/sheets/test2.xlsx
179
184
  - examples/sheets/~$array-formulas.xlsx
180
- - examples/sheets/~$test1.xlsx
181
185
  - examples/unzipped-sheets/array-formulas/[Content_Types].xml
182
186
  - examples/unzipped-sheets/array-formulas/docProps/app.xml
183
187
  - examples/unzipped-sheets/array-formulas/docProps/core.xml
@@ -236,6 +240,20 @@ files:
236
240
  - examples/unzipped-sheets/complex-test/xl/worksheets/_rels/sheet2.xml.rels
237
241
  - examples/unzipped-sheets/complex-test/xl/worksheets/sheet1.xml
238
242
  - examples/unzipped-sheets/complex-test/xl/worksheets/sheet2.xml
243
+ - examples/unzipped-sheets/example/[Content_Types].xml
244
+ - examples/unzipped-sheets/example/docProps/app.xml
245
+ - examples/unzipped-sheets/example/docProps/core.xml
246
+ - examples/unzipped-sheets/example/xl/_rels/workbook.xml.rels
247
+ - examples/unzipped-sheets/example/xl/calcChain.xml
248
+ - examples/unzipped-sheets/example/xl/printerSettings/printerSettings1.bin
249
+ - examples/unzipped-sheets/example/xl/sharedStrings.xml
250
+ - examples/unzipped-sheets/example/xl/styles.xml
251
+ - examples/unzipped-sheets/example/xl/theme/theme1.xml
252
+ - examples/unzipped-sheets/example/xl/workbook.xml
253
+ - examples/unzipped-sheets/example/xl/worksheets/_rels/sheet1.xml.rels
254
+ - examples/unzipped-sheets/example/xl/worksheets/sheet1.xml
255
+ - examples/unzipped-sheets/example/xl/worksheets/sheet2.xml
256
+ - examples/unzipped-sheets/example/xl/worksheets/sheet3.xml
239
257
  - examples/unzipped-sheets/namedReferenceTest/[Content_Types].xml
240
258
  - examples/unzipped-sheets/namedReferenceTest/docProps/app.xml
241
259
  - examples/unzipped-sheets/namedReferenceTest/docProps/core.xml
Binary file
Binary file
Binary file