fpspreadsheet: Improved format detection when reading biff files. Unit test without errors due to biff now again. Fix compilation error of other formats due to new NumFormatList.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3048 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2014-05-15 12:53:56 +00:00
parent 5cdd884f56
commit dae7caff9c
8 changed files with 337 additions and 206 deletions

View File

@ -107,7 +107,7 @@
<PackageName Value="LCL"/> <PackageName Value="LCL"/>
</Item2> </Item2>
</RequiredPackages> </RequiredPackages>
<Units Count="57"> <Units Count="59">
<Unit0> <Unit0>
<Filename Value="fpsgrid.lpr"/> <Filename Value="fpsgrid.lpr"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
@ -139,9 +139,12 @@
<UnitName Value="fpspreadsheet"/> <UnitName Value="fpspreadsheet"/>
<EditorIndex Value="3"/> <EditorIndex Value="3"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="2539"/> <TopLine Value="1"/>
<CursorPos X="19" Y="2550"/> <CursorPos X="1" Y="1"/>
<UsageCount Value="100"/> <UsageCount Value="100"/>
<Bookmarks Count="1">
<Item0 X="13" Y="2613" ID="1"/>
</Bookmarks>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit2> </Unit2>
<Unit3> <Unit3>
@ -149,8 +152,8 @@
<UnitName Value="fpspreadsheetgrid"/> <UnitName Value="fpspreadsheetgrid"/>
<EditorIndex Value="2"/> <EditorIndex Value="2"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="525"/> <TopLine Value="1774"/>
<CursorPos X="30" Y="533"/> <CursorPos X="26" Y="1785"/>
<UsageCount Value="100"/> <UsageCount Value="100"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit3> </Unit3>
@ -160,7 +163,7 @@
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="25"/> <TopLine Value="25"/>
<CursorPos X="4" Y="44"/> <CursorPos X="4" Y="44"/>
<UsageCount Value="6"/> <UsageCount Value="5"/>
</Unit4> </Unit4>
<Unit5> <Unit5>
<Filename Value="c:\lazarus27\fpc\2.2.4\source\packages\winunits-base\src\activex.pp"/> <Filename Value="c:\lazarus27\fpc\2.2.4\source\packages\winunits-base\src\activex.pp"/>
@ -168,7 +171,7 @@
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="49"/> <TopLine Value="49"/>
<CursorPos X="10" Y="24"/> <CursorPos X="10" Y="24"/>
<UsageCount Value="6"/> <UsageCount Value="5"/>
</Unit5> </Unit5>
<Unit6> <Unit6>
<Filename Value="c:\lazarus27\fpc\2.2.4\source\packages\fcl-base\src\avl_tree.pp"/> <Filename Value="c:\lazarus27\fpc\2.2.4\source\packages\fcl-base\src\avl_tree.pp"/>
@ -176,7 +179,7 @@
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="37"/> <TopLine Value="37"/>
<CursorPos X="14" Y="83"/> <CursorPos X="14" Y="83"/>
<UsageCount Value="6"/> <UsageCount Value="5"/>
</Unit6> </Unit6>
<Unit7> <Unit7>
<Filename Value="c:\Lazarus\lcl\grids.pas"/> <Filename Value="c:\Lazarus\lcl\grids.pas"/>
@ -184,14 +187,14 @@
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="1516"/> <TopLine Value="1516"/>
<CursorPos X="28" Y="1534"/> <CursorPos X="28" Y="1534"/>
<UsageCount Value="6"/> <UsageCount Value="5"/>
</Unit7> </Unit7>
<Unit8> <Unit8>
<Filename Value="c:\Lazarus\lcl\include\customform.inc"/> <Filename Value="c:\Lazarus\lcl\include\customform.inc"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="2021"/> <TopLine Value="2021"/>
<CursorPos X="1" Y="2041"/> <CursorPos X="1" Y="2041"/>
<UsageCount Value="6"/> <UsageCount Value="5"/>
</Unit8> </Unit8>
<Unit9> <Unit9>
<Filename Value="..\..\fpsallformats.pas"/> <Filename Value="..\..\fpsallformats.pas"/>
@ -199,7 +202,7 @@
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<CursorPos X="62" Y="13"/> <CursorPos X="62" Y="13"/>
<UsageCount Value="6"/> <UsageCount Value="5"/>
</Unit9> </Unit9>
<Unit10> <Unit10>
<Filename Value="..\..\wikitable.pas"/> <Filename Value="..\..\wikitable.pas"/>
@ -207,7 +210,7 @@
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="48"/> <TopLine Value="48"/>
<CursorPos X="41" Y="60"/> <CursorPos X="41" Y="60"/>
<UsageCount Value="12"/> <UsageCount Value="11"/>
</Unit10> </Unit10>
<Unit11> <Unit11>
<Filename Value="..\..\fpsopendocument.pas"/> <Filename Value="..\..\fpsopendocument.pas"/>
@ -215,27 +218,25 @@
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="1"/> <TopLine Value="1"/>
<CursorPos X="1" Y="1"/> <CursorPos X="1" Y="1"/>
<UsageCount Value="8"/> <UsageCount Value="7"/>
</Unit11> </Unit11>
<Unit12> <Unit12>
<Filename Value="d:\lazarus-svn\lcl\grids.pas"/> <Filename Value="d:\lazarus-svn\lcl\grids.pas"/>
<UnitName Value="Grids"/> <UnitName Value="Grids"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="6"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="4852"/> <TopLine Value="4852"/>
<CursorPos X="16" Y="4884"/> <CursorPos X="16" Y="4884"/>
<UsageCount Value="48"/> <UsageCount Value="47"/>
<Loaded Value="True"/>
</Unit12> </Unit12>
<Unit13> <Unit13>
<Filename Value="..\..\fpsutils.pas"/> <Filename Value="..\..\fpsutils.pas"/>
<UnitName Value="fpsutils"/> <UnitName Value="fpsutils"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="9"/> <EditorIndex Value="9"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="614"/> <TopLine Value="65"/>
<CursorPos X="23" Y="621"/> <CursorPos X="1" Y="78"/>
<UsageCount Value="47"/> <UsageCount Value="51"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit13> </Unit13>
<Unit14> <Unit14>
@ -243,7 +244,7 @@
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="1212"/> <TopLine Value="1212"/>
<CursorPos X="3" Y="1218"/> <CursorPos X="3" Y="1218"/>
<UsageCount Value="4"/> <UsageCount Value="3"/>
</Unit14> </Unit14>
<Unit15> <Unit15>
<Filename Value="d:\lazarus-svn\lcl\graphics.pp"/> <Filename Value="d:\lazarus-svn\lcl\graphics.pp"/>
@ -251,26 +252,23 @@
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="1937"/> <TopLine Value="1937"/>
<CursorPos X="11" Y="1956"/> <CursorPos X="11" Y="1956"/>
<UsageCount Value="33"/> <UsageCount Value="32"/>
</Unit15> </Unit15>
<Unit16> <Unit16>
<Filename Value="d:\lazarus-svn\fpc\2.6.2\source\rtl\objpas\classes\classesh.inc"/> <Filename Value="d:\lazarus-svn\fpc\2.6.2\source\rtl\objpas\classes\classesh.inc"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="248"/> <TopLine Value="248"/>
<CursorPos X="22" Y="263"/> <CursorPos X="22" Y="263"/>
<UsageCount Value="12"/> <UsageCount Value="11"/>
</Unit16> </Unit16>
<Unit17> <Unit17>
<Filename Value="..\..\xlsbiff8.pas"/> <Filename Value="..\..\xlsbiff8.pas"/>
<UnitName Value="xlsbiff8"/> <UnitName Value="xlsbiff8"/>
<EditorIndex Value="5"/> <EditorIndex Value="6"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="1747"/> <TopLine Value="62"/>
<CursorPos X="25" Y="1779"/> <CursorPos X="15" Y="90"/>
<UsageCount Value="78"/> <UsageCount Value="82"/>
<Bookmarks Count="1">
<Item0 X="1" Y="1761" ID="1"/>
</Bookmarks>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit17> </Unit17>
<Unit18> <Unit18>
@ -279,23 +277,23 @@
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="1091"/> <TopLine Value="1091"/>
<CursorPos X="12" Y="1122"/> <CursorPos X="12" Y="1122"/>
<UsageCount Value="8"/> <UsageCount Value="7"/>
</Unit18> </Unit18>
<Unit19> <Unit19>
<Filename Value="d:\lazarus-svn\lcl\include\wincontrol.inc"/> <Filename Value="d:\lazarus-svn\lcl\include\wincontrol.inc"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="7344"/> <TopLine Value="7344"/>
<CursorPos X="30" Y="7349"/> <CursorPos X="30" Y="7349"/>
<UsageCount Value="6"/> <UsageCount Value="5"/>
</Unit19> </Unit19>
<Unit20> <Unit20>
<Filename Value="..\..\xlscommon.pas"/> <Filename Value="..\..\xlscommon.pas"/>
<UnitName Value="xlscommon"/> <UnitName Value="xlscommon"/>
<EditorIndex Value="4"/> <EditorIndex Value="4"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="1207"/> <TopLine Value="608"/>
<CursorPos X="1" Y="1217"/> <CursorPos X="31" Y="634"/>
<UsageCount Value="74"/> <UsageCount Value="78"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit20> </Unit20>
<Unit21> <Unit21>
@ -305,7 +303,7 @@
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="1363"/> <TopLine Value="1363"/>
<CursorPos X="1" Y="1364"/> <CursorPos X="1" Y="1364"/>
<UsageCount Value="61"/> <UsageCount Value="65"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit21> </Unit21>
<Unit22> <Unit22>
@ -315,7 +313,7 @@
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="664"/> <TopLine Value="664"/>
<CursorPos X="21" Y="677"/> <CursorPos X="21" Y="677"/>
<UsageCount Value="62"/> <UsageCount Value="66"/>
<Loaded Value="True"/> <Loaded Value="True"/>
</Unit22> </Unit22>
<Unit23> <Unit23>
@ -324,7 +322,7 @@
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="841"/> <TopLine Value="841"/>
<CursorPos X="19" Y="852"/> <CursorPos X="19" Y="852"/>
<UsageCount Value="1"/> <UsageCount Value="10"/>
</Unit23> </Unit23>
<Unit24> <Unit24>
<Filename Value="d:\lazarus-svn\fpc\2.6.2\source\packages\fcl-image\src\fpcanvas.pp"/> <Filename Value="d:\lazarus-svn\fpc\2.6.2\source\packages\fcl-image\src\fpcanvas.pp"/>
@ -332,7 +330,7 @@
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="111"/> <TopLine Value="111"/>
<CursorPos X="3" Y="112"/> <CursorPos X="3" Y="112"/>
<UsageCount Value="14"/> <UsageCount Value="13"/>
</Unit24> </Unit24>
<Unit25> <Unit25>
<Filename Value="d:\lazarus-svn\fpc\2.6.2\source\packages\fcl-image\src\fpimage.pp"/> <Filename Value="d:\lazarus-svn\fpc\2.6.2\source\packages\fcl-image\src\fpimage.pp"/>
@ -340,14 +338,14 @@
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="74"/> <TopLine Value="74"/>
<CursorPos X="3" Y="93"/> <CursorPos X="3" Y="93"/>
<UsageCount Value="2"/> <UsageCount Value="1"/>
</Unit25> </Unit25>
<Unit26> <Unit26>
<Filename Value="d:\lazarus-svn\fpc\2.6.2\source\rtl\objpas\classes\lists.inc"/> <Filename Value="d:\lazarus-svn\fpc\2.6.2\source\rtl\objpas\classes\lists.inc"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="141"/> <TopLine Value="141"/>
<CursorPos X="3" Y="143"/> <CursorPos X="3" Y="143"/>
<UsageCount Value="10"/> <UsageCount Value="9"/>
</Unit26> </Unit26>
<Unit27> <Unit27>
<Filename Value="d:\Prog_Delphi\common\units\XLS.pas"/> <Filename Value="d:\Prog_Delphi\common\units\XLS.pas"/>
@ -355,14 +353,14 @@
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="114"/> <TopLine Value="114"/>
<CursorPos X="42" Y="152"/> <CursorPos X="42" Y="152"/>
<UsageCount Value="10"/> <UsageCount Value="9"/>
</Unit27> </Unit27>
<Unit28> <Unit28>
<Filename Value="d:\lazarus-svn\lcl\include\pen.inc"/> <Filename Value="d:\lazarus-svn\lcl\include\pen.inc"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="354"/> <TopLine Value="354"/>
<CursorPos X="1" Y="385"/> <CursorPos X="1" Y="385"/>
<UsageCount Value="15"/> <UsageCount Value="14"/>
</Unit28> </Unit28>
<Unit29> <Unit29>
<Filename Value="d:\lazarus-svn\lcl\controls.pp"/> <Filename Value="d:\lazarus-svn\lcl\controls.pp"/>
@ -370,14 +368,14 @@
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="2222"/> <TopLine Value="2222"/>
<CursorPos X="14" Y="2242"/> <CursorPos X="14" Y="2242"/>
<UsageCount Value="10"/> <UsageCount Value="9"/>
</Unit29> </Unit29>
<Unit30> <Unit30>
<Filename Value="d:\lazarus-svn\lcl\include\control.inc"/> <Filename Value="d:\lazarus-svn\lcl\include\control.inc"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="4129"/> <TopLine Value="4129"/>
<CursorPos X="1" Y="4161"/> <CursorPos X="1" Y="4161"/>
<UsageCount Value="9"/> <UsageCount Value="8"/>
</Unit30> </Unit30>
<Unit31> <Unit31>
<Filename Value="..\..\fpspreadsheetchart.pas"/> <Filename Value="..\..\fpspreadsheetchart.pas"/>
@ -385,7 +383,7 @@
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="170"/> <TopLine Value="170"/>
<CursorPos X="37" Y="204"/> <CursorPos X="37" Y="204"/>
<UsageCount Value="5"/> <UsageCount Value="4"/>
</Unit31> </Unit31>
<Unit32> <Unit32>
<Filename Value="d:\lazarus-svn\components\lazutils\lazutf8.pas"/> <Filename Value="d:\lazarus-svn\components\lazutils\lazutf8.pas"/>
@ -393,7 +391,7 @@
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="3180"/> <TopLine Value="3180"/>
<CursorPos X="1" Y="3212"/> <CursorPos X="1" Y="3212"/>
<UsageCount Value="6"/> <UsageCount Value="5"/>
</Unit32> </Unit32>
<Unit33> <Unit33>
<Filename Value="d:\lazarus-svn\lcl\colorbox.pas"/> <Filename Value="d:\lazarus-svn\lcl\colorbox.pas"/>
@ -401,7 +399,7 @@
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="584"/> <TopLine Value="584"/>
<CursorPos X="3" Y="598"/> <CursorPos X="3" Y="598"/>
<UsageCount Value="14"/> <UsageCount Value="13"/>
</Unit33> </Unit33>
<Unit34> <Unit34>
<Filename Value="d:\lazarus-svn\lcl\dialogs.pp"/> <Filename Value="d:\lazarus-svn\lcl\dialogs.pp"/>
@ -409,7 +407,7 @@
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="222"/> <TopLine Value="222"/>
<CursorPos X="3" Y="253"/> <CursorPos X="3" Y="253"/>
<UsageCount Value="6"/> <UsageCount Value="5"/>
</Unit34> </Unit34>
<Unit35> <Unit35>
<Filename Value="d:\lazarus-svn\lcl\forms.pp"/> <Filename Value="d:\lazarus-svn\lcl\forms.pp"/>
@ -417,7 +415,7 @@
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="932"/> <TopLine Value="932"/>
<CursorPos X="3" Y="939"/> <CursorPos X="3" Y="939"/>
<UsageCount Value="6"/> <UsageCount Value="5"/>
</Unit35> </Unit35>
<Unit36> <Unit36>
<Filename Value="C:\development\lazarus\lcl\graphics.pp"/> <Filename Value="C:\development\lazarus\lcl\graphics.pp"/>
@ -425,7 +423,7 @@
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="2053"/> <TopLine Value="2053"/>
<CursorPos X="30" Y="1945"/> <CursorPos X="30" Y="1945"/>
<UsageCount Value="9"/> <UsageCount Value="8"/>
</Unit36> </Unit36>
<Unit37> <Unit37>
<Filename Value="C:\development\fpc\packages\fcl-image\src\fpcanvas.pp"/> <Filename Value="C:\development\fpc\packages\fcl-image\src\fpcanvas.pp"/>
@ -433,14 +431,14 @@
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="89"/> <TopLine Value="89"/>
<CursorPos X="15" Y="97"/> <CursorPos X="15" Y="97"/>
<UsageCount Value="8"/> <UsageCount Value="7"/>
</Unit37> </Unit37>
<Unit38> <Unit38>
<Filename Value="C:\development\fpc\packages\fcl-image\src\fpfont.inc"/> <Filename Value="C:\development\fpc\packages\fcl-image\src\fpfont.inc"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="54"/> <TopLine Value="54"/>
<CursorPos X="3" Y="57"/> <CursorPos X="3" Y="57"/>
<UsageCount Value="8"/> <UsageCount Value="7"/>
</Unit38> </Unit38>
<Unit39> <Unit39>
<Filename Value="C:\development\lazarus\lcl\graphmath.pp"/> <Filename Value="C:\development\lazarus\lcl\graphmath.pp"/>
@ -448,7 +446,7 @@
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="584"/> <TopLine Value="584"/>
<CursorPos X="3" Y="439"/> <CursorPos X="3" Y="439"/>
<UsageCount Value="8"/> <UsageCount Value="7"/>
</Unit39> </Unit39>
<Unit40> <Unit40>
<Filename Value="C:\development\lazarus\lcl\graphtype.pp"/> <Filename Value="C:\development\lazarus\lcl\graphtype.pp"/>
@ -456,7 +454,7 @@
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="234"/> <TopLine Value="234"/>
<CursorPos X="3" Y="33"/> <CursorPos X="3" Y="33"/>
<UsageCount Value="8"/> <UsageCount Value="7"/>
</Unit40> </Unit40>
<Unit41> <Unit41>
<Filename Value="C:\development\lazarus\lcl\lcltype.pp"/> <Filename Value="C:\development\lazarus\lcl\lcltype.pp"/>
@ -464,7 +462,7 @@
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="1628"/> <TopLine Value="1628"/>
<CursorPos X="3" Y="1643"/> <CursorPos X="3" Y="1643"/>
<UsageCount Value="8"/> <UsageCount Value="7"/>
</Unit41> </Unit41>
<Unit42> <Unit42>
<Filename Value="C:\development\lazarus\lcl\graphutil.pp"/> <Filename Value="C:\development\lazarus\lcl\graphutil.pp"/>
@ -472,7 +470,7 @@
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="128"/> <TopLine Value="128"/>
<CursorPos X="12" Y="143"/> <CursorPos X="12" Y="143"/>
<UsageCount Value="8"/> <UsageCount Value="7"/>
</Unit42> </Unit42>
<Unit43> <Unit43>
<Filename Value="C:\development\fpc\rtl\objpas\math.pp"/> <Filename Value="C:\development\fpc\rtl\objpas\math.pp"/>
@ -480,14 +478,16 @@
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="144"/> <TopLine Value="144"/>
<CursorPos X="10" Y="159"/> <CursorPos X="10" Y="159"/>
<UsageCount Value="11"/> <UsageCount Value="10"/>
</Unit43> </Unit43>
<Unit44> <Unit44>
<Filename Value="C:\development\fpc\rtl\i386\i386.inc"/> <Filename Value="C:\development\fpc\rtl\i386\i386.inc"/>
<EditorIndex Value="5"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="1551"/> <TopLine Value="1497"/>
<CursorPos X="3" Y="1563"/> <CursorPos X="1" Y="1515"/>
<UsageCount Value="9"/> <UsageCount Value="13"/>
<Loaded Value="True"/>
</Unit44> </Unit44>
<Unit45> <Unit45>
<Filename Value="C:\development\lazarus\lcl\grids.pas"/> <Filename Value="C:\development\lazarus\lcl\grids.pas"/>
@ -495,7 +495,7 @@
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="794"/> <TopLine Value="794"/>
<CursorPos X="15" Y="1010"/> <CursorPos X="15" Y="1010"/>
<UsageCount Value="15"/> <UsageCount Value="14"/>
</Unit45> </Unit45>
<Unit46> <Unit46>
<Filename Value="..\..\..\spktoolbar\SpkGraphTools\SpkGraphTools.pas"/> <Filename Value="..\..\..\spktoolbar\SpkGraphTools\SpkGraphTools.pas"/>
@ -503,199 +503,213 @@
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="136"/> <TopLine Value="136"/>
<CursorPos X="1" Y="143"/> <CursorPos X="1" Y="143"/>
<UsageCount Value="6"/> <UsageCount Value="5"/>
</Unit46> </Unit46>
<Unit47> <Unit47>
<Filename Value="C:\development\fpc\rtl\objpas\classes\lists.inc"/> <Filename Value="C:\development\fpc\rtl\objpas\classes\lists.inc"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="34"/> <TopLine Value="34"/>
<CursorPos X="1" Y="49"/> <CursorPos X="1" Y="49"/>
<UsageCount Value="14"/> <UsageCount Value="13"/>
</Unit47> </Unit47>
<Unit48> <Unit48>
<Filename Value="C:\development\lazarus\lcl\include\canvas.inc"/> <Filename Value="C:\development\lazarus\lcl\include\canvas.inc"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="1705"/> <TopLine Value="1705"/>
<CursorPos X="1" Y="1720"/> <CursorPos X="1" Y="1720"/>
<UsageCount Value="14"/> <UsageCount Value="13"/>
</Unit48> </Unit48>
<Unit49> <Unit49>
<Filename Value="C:\development\lazarus\lcl\include\font.inc"/> <Filename Value="C:\development\lazarus\lcl\include\font.inc"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="1139"/> <TopLine Value="1139"/>
<CursorPos X="25" Y="1161"/> <CursorPos X="25" Y="1161"/>
<UsageCount Value="14"/> <UsageCount Value="13"/>
</Unit49> </Unit49>
<Unit50> <Unit50>
<Filename Value="C:\development\lazarus\lcl\include\winapih.inc"/> <Filename Value="C:\development\lazarus\lcl\include\winapih.inc"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="156"/> <TopLine Value="156"/>
<CursorPos X="10" Y="171"/> <CursorPos X="10" Y="171"/>
<UsageCount Value="8"/> <UsageCount Value="7"/>
</Unit50> </Unit50>
<Unit51> <Unit51>
<Filename Value="C:\development\lazarus\lcl\include\intfbasewinapi.inc"/> <Filename Value="C:\development\lazarus\lcl\include\intfbasewinapi.inc"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="1577"/> <TopLine Value="1577"/>
<CursorPos X="3" Y="1579"/> <CursorPos X="3" Y="1579"/>
<UsageCount Value="8"/> <UsageCount Value="7"/>
</Unit51> </Unit51>
<Unit52> <Unit52>
<Filename Value="C:\development\fpc\rtl\inc\except.inc"/> <Filename Value="C:\development\fpc\rtl\inc\except.inc"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="202"/> <TopLine Value="202"/>
<CursorPos X="1" Y="227"/> <CursorPos X="1" Y="227"/>
<UsageCount Value="8"/> <UsageCount Value="12"/>
</Unit52> </Unit52>
<Unit53> <Unit53>
<Filename Value="d:\lazarus-svn\lcl\include\menuitem.inc"/> <Filename Value="d:\lazarus-svn\lcl\include\menuitem.inc"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="69"/> <TopLine Value="69"/>
<CursorPos X="28" Y="82"/> <CursorPos X="28" Y="82"/>
<UsageCount Value="14"/> <UsageCount Value="13"/>
</Unit53> </Unit53>
<Unit54> <Unit54>
<Filename Value="d:\lazarus-svn\lcl\include\application.inc"/> <Filename Value="d:\lazarus-svn\lcl\include\application.inc"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="1371"/> <TopLine Value="1371"/>
<CursorPos X="1" Y="1390"/> <CursorPos X="1" Y="1390"/>
<UsageCount Value="13"/> <UsageCount Value="12"/>
</Unit54> </Unit54>
<Unit55> <Unit55>
<Filename Value="d:\lazarus-svn\lcl\include\font.inc"/> <Filename Value="d:\lazarus-svn\lcl\include\font.inc"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="648"/> <TopLine Value="648"/>
<CursorPos X="1" Y="675"/> <CursorPos X="1" Y="675"/>
<UsageCount Value="12"/> <UsageCount Value="11"/>
</Unit55> </Unit55>
<Unit56> <Unit56>
<Filename Value="d:\lazarus-svn\lcl\include\fontdialog.inc"/> <Filename Value="d:\lazarus-svn\lcl\include\fontdialog.inc"/>
<WindowIndex Value="0"/> <WindowIndex Value="0"/>
<TopLine Value="24"/> <TopLine Value="24"/>
<CursorPos X="1" Y="49"/> <CursorPos X="1" Y="49"/>
<UsageCount Value="12"/> <UsageCount Value="11"/>
</Unit56> </Unit56>
<Unit57>
<Filename Value="C:\development\fpc\rtl\objpas\sysutils\sysinth.inc"/>
<WindowIndex Value="0"/>
<TopLine Value="50"/>
<CursorPos X="3" Y="57"/>
<UsageCount Value="10"/>
</Unit57>
<Unit58>
<Filename Value="C:\development\fpc\rtl\inc\wstrings.inc"/>
<WindowIndex Value="0"/>
<TopLine Value="169"/>
<CursorPos X="1" Y="185"/>
<UsageCount Value="10"/>
</Unit58>
</Units> </Units>
<JumpHistory Count="30" HistoryIndex="29"> <JumpHistory Count="30" HistoryIndex="29">
<Position1> <Position1>
<Filename Value="..\..\xlsbiff8.pas"/> <Filename Value="..\..\xlscommon.pas"/>
<Caret Line="1753" Column="1" TopLine="1738"/> <Caret Line="783" Column="1" TopLine="768"/>
</Position1> </Position1>
<Position2> <Position2>
<Filename Value="..\..\xlsbiff8.pas"/> <Filename Value="..\..\xlscommon.pas"/>
<Caret Line="1968" Column="1" TopLine="1928"/> <Caret Line="804" Column="1" TopLine="788"/>
</Position2> </Position2>
<Position3> <Position3>
<Filename Value="..\..\xlsbiff8.pas"/> <Filename Value="..\..\xlscommon.pas"/>
<Caret Line="1" Column="1" TopLine="1"/> <Caret Line="805" Column="1" TopLine="788"/>
</Position3> </Position3>
<Position4> <Position4>
<Filename Value="..\..\xlsbiff8.pas"/> <Filename Value="..\..\xlscommon.pas"/>
<Caret Line="80" Column="21" TopLine="47"/> <Caret Line="817" Column="32" TopLine="788"/>
</Position4> </Position4>
<Position5> <Position5>
<Filename Value="..\..\xlsbiff8.pas"/> <Filename Value="..\..\xlscommon.pas"/>
<Caret Line="1760" Column="1" TopLine="1744"/> <Caret Line="807" Column="1" TopLine="788"/>
</Position5> </Position5>
<Position6> <Position6>
<Filename Value="..\..\xlsbiff8.pas"/> <Filename Value="..\..\xlscommon.pas"/>
<Caret Line="95" Column="22" TopLine="75"/> <Caret Line="808" Column="1" TopLine="788"/>
</Position6> </Position6>
<Position7> <Position7>
<Filename Value="..\..\xlsbiff8.pas"/> <Filename Value="..\..\xlscommon.pas"/>
<Caret Line="1" Column="1" TopLine="1"/> <Caret Line="784" Column="1" TopLine="769"/>
</Position7> </Position7>
<Position8> <Position8>
<Filename Value="..\..\xlsbiff8.pas"/> <Filename Value="..\..\xlscommon.pas"/>
<Caret Line="1524" Column="37" TopLine="1516"/> <Caret Line="785" Column="1" TopLine="769"/>
</Position8> </Position8>
<Position9> <Position9>
<Filename Value="..\..\xlsbiff8.pas"/> <Filename Value="..\..\xlscommon.pas"/>
<Caret Line="1649" Column="21" TopLine="1622"/> <Caret Line="786" Column="1" TopLine="769"/>
</Position9> </Position9>
<Position10> <Position10>
<Filename Value="..\..\xlsbiff8.pas"/> <Filename Value="..\..\xlscommon.pas"/>
<Caret Line="1527" Column="3" TopLine="1524"/> <Caret Line="787" Column="1" TopLine="769"/>
</Position10> </Position10>
<Position11> <Position11>
<Filename Value="..\..\xlsbiff8.pas"/> <Filename Value="..\..\xlscommon.pas"/>
<Caret Line="1758" Column="3" TopLine="1733"/> <Caret Line="788" Column="1" TopLine="769"/>
</Position11> </Position11>
<Position12> <Position12>
<Filename Value="..\..\xlsbiff8.pas"/> <Filename Value="..\..\xlscommon.pas"/>
<Caret Line="1" Column="1" TopLine="1"/> <Caret Line="794" Column="1" TopLine="769"/>
</Position12> </Position12>
<Position13> <Position13>
<Filename Value="..\..\xlsbiff8.pas"/> <Filename Value="..\..\xlscommon.pas"/>
<Caret Line="51" Column="19" TopLine="18"/> <Caret Line="1108" Column="1" TopLine="1093"/>
</Position13> </Position13>
<Position14> <Position14>
<Filename Value="..\..\xlsbiff8.pas"/> <Filename Value="..\..\xlscommon.pas"/>
<Caret Line="57" Column="11" TopLine="24"/> <Caret Line="1109" Column="1" TopLine="1093"/>
</Position14> </Position14>
<Position15> <Position15>
<Filename Value="..\..\xlsbiff8.pas"/> <Filename Value="..\..\fpspreadsheet.pas"/>
<Caret Line="67" Column="13" TopLine="34"/> <Caret Line="1461" Column="1" TopLine="1445"/>
</Position15> </Position15>
<Position16> <Position16>
<Filename Value="..\..\xlsbiff8.pas"/> <Filename Value="..\..\fpspreadsheet.pas"/>
<Caret Line="1394" Column="3" TopLine="1388"/> <Caret Line="1462" Column="1" TopLine="1445"/>
</Position16> </Position16>
<Position17> <Position17>
<Filename Value="..\..\xlsbiff8.pas"/> <Filename Value="..\..\fpspreadsheet.pas"/>
<Caret Line="1761" Column="3" TopLine="1738"/> <Caret Line="1464" Column="1" TopLine="1445"/>
</Position17> </Position17>
<Position18> <Position18>
<Filename Value="..\..\xlsbiff8.pas"/> <Filename Value="..\..\fpspreadsheet.pas"/>
<Caret Line="95" Column="75" TopLine="76"/> <Caret Line="1465" Column="1" TopLine="1451"/>
</Position18> </Position18>
<Position19> <Position19>
<Filename Value="..\..\xlsbiff8.pas"/> <Filename Value="..\..\fpspreadsheet.pas"/>
<Caret Line="1749" Column="8" TopLine="1747"/> <Caret Line="1469" Column="1" TopLine="1451"/>
</Position19> </Position19>
<Position20> <Position20>
<Filename Value="..\..\xlsbiff8.pas"/> <Filename Value="..\..\fpspreadsheet.pas"/>
<Caret Line="95" Column="55" TopLine="95"/> <Caret Line="1470" Column="1" TopLine="1451"/>
</Position20> </Position20>
<Position21> <Position21>
<Filename Value="..\..\xlsbiff8.pas"/> <Filename Value="..\..\fpspreadsheet.pas"/>
<Caret Line="1748" Column="49" TopLine="1733"/> <Caret Line="1471" Column="1" TopLine="1451"/>
</Position21> </Position21>
<Position22> <Position22>
<Filename Value="..\..\xlsbiff8.pas"/> <Filename Value="..\..\fpspreadsheet.pas"/>
<Caret Line="95" Column="55" TopLine="95"/> <Caret Line="1485" Column="39" TopLine="1468"/>
</Position22> </Position22>
<Position23> <Position23>
<Filename Value="..\..\xlsbiff8.pas"/> <Filename Value="..\..\fpsutils.pas"/>
<Caret Line="1749" Column="8" TopLine="1747"/> <Caret Line="913" Column="46" TopLine="884"/>
</Position23> </Position23>
<Position24> <Position24>
<Filename Value="..\..\xlsbiff5.pas"/> <Filename Value="..\..\fpsutils.pas"/>
<Caret Line="1370" Column="1" TopLine="1358"/> <Caret Line="83" Column="3" TopLine="52"/>
</Position24> </Position24>
<Position25> <Position25>
<Filename Value="..\..\xlscommon.pas"/> <Filename Value="..\..\fpspreadsheet.pas"/>
<Caret Line="39" Column="3" TopLine="10"/> <Caret Line="1485" Column="42" TopLine="1459"/>
</Position25> </Position25>
<Position26> <Position26>
<Filename Value="..\..\xlsbiff2.pas"/> <Filename Value="..\..\fpspreadsheet.pas"/>
<Caret Line="677" Column="21" TopLine="664"/> <Caret Line="1" Column="1" TopLine="1"/>
</Position26> </Position26>
<Position27> <Position27>
<Filename Value="..\..\fpspreadsheetgrid.pas"/> <Filename Value="..\..\fpspreadsheet.pas"/>
<Caret Line="524" Column="27" TopLine="524"/> <Caret Line="2612" Column="3" TopLine="2674"/>
</Position27> </Position27>
<Position28> <Position28>
<Filename Value="..\..\fpspreadsheetgrid.pas"/> <Filename Value="..\..\xlscommon.pas"/>
<Caret Line="1" Column="1" TopLine="1"/> <Caret Line="581" Column="3" TopLine="573"/>
</Position28> </Position28>
<Position29> <Position29>
<Filename Value="..\..\fpspreadsheetgrid.pas"/> <Filename Value="..\..\xlscommon.pas"/>
<Caret Line="1787" Column="3" TopLine="1779"/> <Caret Line="1" Column="1" TopLine="1"/>
</Position29> </Position29>
<Position30> <Position30>
<Filename Value="..\..\xlsbiff8.pas"/> <Filename Value="..\..\fpsutils.pas"/>
<Caret Line="1779" Column="25" TopLine="1747"/> <Caret Line="1157" Column="1" TopLine="1131"/>
</Position30> </Position30>
</JumpHistory> </JumpHistory>
</ProjectOptions> </ProjectOptions>
@ -725,15 +739,6 @@
</Other> </Other>
</CompilerOptions> </CompilerOptions>
<Debugging> <Debugging>
<BreakPoints Count="1">
<Item1>
<Kind Value="bpkSource"/>
<WatchScope Value="wpsLocal"/>
<WatchKind Value="wpkWrite"/>
<Source Value="..\..\fpspreadsheetgrid.pas"/>
<Line Value="1790"/>
</Item1>
</BreakPoints>
<Watches Count="2"> <Watches Count="2">
<Item1> <Item1>
<Expression Value="acol"/> <Expression Value="acol"/>

View File

@ -13,7 +13,7 @@ program test_write_formatting;
uses uses
Classes, SysUtils, fpspreadsheet, xlsbiff8, fpsopendocument, Classes, SysUtils, fpspreadsheet, xlsbiff8, fpsopendocument,
laz_fpspreadsheet, fpsconvencoding; laz_fpspreadsheet;
var var
MyWorkbook: TsWorkbook; MyWorkbook: TsWorkbook;

View File

@ -12,7 +12,7 @@ program test_write_formula;
uses uses
Classes, SysUtils, Classes, SysUtils,
fpspreadsheet, xlsbiff5, xlsbiff8, fpsopendocument, fpspreadsheet, xlsbiff5, xlsbiff8, fpsopendocument,
laz_fpspreadsheet, fpsconvencoding; laz_fpspreadsheet;
var var
MyWorkbook: TsWorkbook; MyWorkbook: TsWorkbook;

View File

@ -521,8 +521,8 @@ type
FFirstFormatIndexInFile: Integer; FFirstFormatIndexInFile: Integer;
FNextFormatIndex: Integer; FNextFormatIndex: Integer;
procedure AddBuiltinFormats; virtual; procedure AddBuiltinFormats; virtual;
procedure Analyze(var AFormatString: String; var ANumFormat: TsNumberFormat; procedure Analyze(AFormatIndex: Integer; var AFormatString: String;
var ADecimals: Word); virtual; var ANumFormat: TsNumberFormat; var ADecimals: Word); virtual;
procedure RemoveFormat(AIndex: Integer); procedure RemoveFormat(AIndex: Integer);
public public
constructor Create; constructor Create;
@ -555,7 +555,7 @@ type
FWorkbook: TsWorkbook; FWorkbook: TsWorkbook;
FWorksheet: TsWorksheet; FWorksheet: TsWorksheet;
FNumFormatList: TsCustomNumFormatList; FNumFormatList: TsCustomNumFormatList;
procedure CreateNumFormatList; virtual; abstract; procedure CreateNumFormatList; virtual;
{ Record reading methods } { Record reading methods }
procedure ReadBlank(AStream: TStream); virtual; abstract; procedure ReadBlank(AStream: TStream); virtual; abstract;
procedure ReadFormula(AStream: TStream); virtual; abstract; procedure ReadFormula(AStream: TStream); virtual; abstract;
@ -587,7 +587,7 @@ type
FNumFormatList: TsCustomNumFormatList; FNumFormatList: TsCustomNumFormatList;
{ Helper routines } { Helper routines }
procedure AddDefaultFormats(); virtual; procedure AddDefaultFormats(); virtual;
procedure CreateNumFormatList; virtual; abstract; procedure CreateNumFormatList; virtual;
function ExpandFormula(AFormula: TsFormula): TsExpandedFormula; function ExpandFormula(AFormula: TsFormula): TsExpandedFormula;
function FindFormattingInList(AFormat: PCell): Integer; function FindFormattingInList(AFormat: PCell): Integer;
procedure FixFormat(ACell: PCell); virtual; procedure FixFormat(ACell: PCell); virtual;
@ -1480,20 +1480,20 @@ begin
nfLongTime: nfLongTime:
ACell^.NumberFormatStr := 'tt'; ACell^.NumberFormatStr := 'tt';
nfShortTimeAM: nfShortTimeAM:
ACell^.NumberFormatStr := 't am/pm'; ACell^.NumberFormatStr := 'hh:nn AM/PM';
nfLongTimeAM: nfLongTimeAM:
ACell^.NumberFormatStr := 'tt am/pm'; ACell^.NumberFormatStr := 'hh:nn:ss AM/PM';
nfFmtDateTime: nfFmtDateTime:
begin begin
fmt := lowercase(AFormatStr); fmt := lowercase(AFormatStr);
if fmt = 'dm' then ACell^.NumberFormatStr := 'd/mmm' if fmt = 'dm' then ACell^.NumberFormatStr := 'd/mmm'
else if fmt = 'my' then ACell^.NumberFormatStr := 'mmm/yy' else if fmt = 'my' then ACell^.NumberFormatStr := 'mmm/yy'
else if fmt = 'ms' then ACell^.NumberFormatStr := 'mm:ss' // Excel does not like the "n" else if fmt = 'ms' then ACell^.NumberFormatStr := 'nn:ss'
else if fmt = 'msz' then ACell^.NumberFormatStr := 'mm:ss.z' else if fmt = 'msz' then ACell^.NumberFormatStr := 'nn:ss.z'
else ACell^.NumberFormatStr := AFormatStr; else ACell^.NumberFormatStr := AFormatStr;
end; end;
nfTimeInterval: nfTimeInterval:
if AFormatStr = '' then ACell^.NumberFormatStr := '[h]:mm:ss' if AFormatStr = '' then ACell^.NumberFormatStr := '[h]:nn:ss'
else ACell^.NumberFormatStr := AFormatStr; else ACell^.NumberFormatStr := AFormatStr;
end; end;
ChangedCell(ARow, ACol); ChangedCell(ARow, ACol);
@ -2564,10 +2564,14 @@ begin
inc(FNextFormatIndex); inc(FNextFormatIndex);
end; end;
{ Adds the builtin format items to the list. Must be called before user items { Adds the builtin format items to the list. The formats must be specified in
are added. Must specify FFirstFormatIndexInFile (BIFF5-8, e.g. don't save a way which can be understood by fpc.
formats <164) and must initialize the index of the first user format If fpc and file speak different languages "translation" must be made in
(FNextFormatIndex) which is automatically incremented when adding user formats. } "Analyze" for reading and "FormatStringForWriting" for writing.
Must be called before user items are added.
Must specify FFirstFormatIndexInFile (BIFF5-8, e.g. doesn't save formats <164)
and must initialize the index of the first user format (FNextFormatIndex)
which is automatically incremented when adding user formats. }
procedure TsCustomNumFormatList.AddBuiltinFormats; procedure TsCustomNumFormatList.AddBuiltinFormats;
begin begin
// must be overridden // must be overridden
@ -2575,12 +2579,13 @@ end;
{ Takes the format string (AFormatString) as it is read from the file and { Takes the format string (AFormatString) as it is read from the file and
extracts the number format type (ANumFormat) and the number of decimals extracts the number format type (ANumFormat) and the number of decimals
(ADecimals) out of it. If the format string cannot be directly handled by (ADecimals) out of it for use by fpc.
fpc it has to be transformed to make it compatible. Can be done in If the format string cannot be directly handled by fpc it has to be transformed
overridden versions which know more about the structure of the string in to make it compatible. Can be done in overridden versions which know more
the actual file format. } about the structure of the string in the actual file format. }
procedure TsCustomNumFormatList.Analyze(var AFormatString: String; procedure TsCustomNumFormatList.Analyze(AFormatIndex: Integer;
var ANumFormat: TsNumberFormat; var ADecimals: Word); var AFormatString: String; var ANumFormat: TsNumberFormat;
var ADecimals: Word);
const const
SHORT_LONG_DATE: array[boolean] of TsNumberFormat = ( SHORT_LONG_DATE: array[boolean] of TsNumberFormat = (
nfShortDate, nfLongDate nfShortDate, nfLongDate
@ -2600,7 +2605,42 @@ var
isInterval: Boolean; isInterval: Boolean;
isSci: Boolean; isSci: Boolean;
isTime, isDate: Boolean; isTime, isDate: Boolean;
lFormatData: TsNumFormatData;
i: Integer;
fmt: String;
begin begin
{ Check the built-in formats first }
i := Find(AFormatIndex);
if i > 0 then begin
lFormatData := Items[i];
case lFormatData.NumFormat of
nfFixed, nfFixedTh, nfPercentage, nfExp, nfSci:
begin
ANumFormat := lFormatData.NumFormat;
AFormatString := lFormatData.FormatString;
ADecimals := lFormatData.Decimals;
exit;
end;
nfShortDateTime, nfShortDate, nfLongDate,
nfShortTime, nfLongTime, nfShortTimeAM, nfLongTimeAM, nfTimeInterval:
begin
ANumFormat := lFormatData.NumFormat;
AFormatString := lFormatData.FormatString;
ADecimals := 0;
exit;
end;
nfFmtDateTime:
begin
ANumFormat := lFormatData.NumFormat;
AFormatString := lFormatData.FormatString;
IsTimeFormat(AFormatString, isLongTime, isAMPM, isInterval, ADecimals);
exit;
end;
end;
end;
{ Then check the non-standard formats. There is a chance that they may not be
reckognized correctly... }
ANumFormat := nfGeneral; ANumFormat := nfGeneral;
if IsPercentNumberFormat(AFormatString, ADecimals) then if IsPercentNumberFormat(AFormatString, ADecimals) then
ANumFormat := nfPercentage ANumFormat := nfPercentage
@ -2648,7 +2688,7 @@ begin
raise Exception.Create('TsCustomNumFormatList.AnalyzeAndAdd: Format index must be unique.'); raise Exception.Create('TsCustomNumFormatList.AnalyzeAndAdd: Format index must be unique.');
// Analyze the format string and extract information for internal formatting // Analyze the format string and extract information for internal formatting
Analyze(AFormatString, nf, decs); Analyze(AFormatIndex, AFormatString, nf, decs);
// Add the new item // Add the new item
AddFormat(AFormatIndex, nf, AFormatString, decs); AddFormat(AFormatIndex, nf, AFormatString, decs);
@ -2828,6 +2868,12 @@ begin
inherited Destroy; inherited Destroy;
end; end;
procedure TsCustomSpreadReader.CreateNumFormatList;
begin
{ The format list needs to be created by descendants who know about the
special requirements of the file format. }
end;
{@@ {@@
Default file reading method. Default file reading method.
@ -2979,6 +3025,12 @@ begin
NextXFIndex := 0; NextXFIndex := 0;
end; end;
procedure TsCustomSpreadWriter.CreateNumFormatList;
begin
{ The format list needs to be created by descendants who know about the
special requirements of the file format. }
end;
procedure TsCustomSpreadWriter.ListAllFormattingStylesCallback(ACell: PCell; AStream: TStream); procedure TsCustomSpreadWriter.ListAllFormattingStylesCallback(ACell: PCell; AStream: TStream);
var var
Len: Integer; Len: Integer;

View File

@ -653,8 +653,11 @@ end;
{ IsDateFormat checks if the format string s corresponds to a date format } { IsDateFormat checks if the format string s corresponds to a date format }
function IsDateFormat(s: String; out IsLong: Boolean): Boolean; function IsDateFormat(s: String; out IsLong: Boolean): Boolean;
begin begin
s := Lowercase(s);
// Day, month, year are separated by a slash // Day, month, year are separated by a slash
Result := (pos('/', s) > 0); // We also check part of the year/month/day symbol because there may be
// other control code with a slash.
Result := (pos('y/', s) > 0) or (pos('m/', s) > 0) or (pos('/m', s) > 0) or (pos('/d', s) > 0);
if Result then if Result then
// Check validity of format string // Check validity of format string
try try
@ -688,6 +691,13 @@ begin
count := 1; count := 1;
s := Uppercase(s); s := Uppercase(s);
// Seek for "H:MM:SS" or "H:MM" to see if it is a long or short time format.
if pos('H:MM:SS', s) <> 0 then
isLong := true
else
if pos('H:MM', s) <> 0 then
isLong := false
else
// If there are is a second colon s is a "long" time format // If there are is a second colon s is a "long" time format
for i:=p+1 to Length(s) do for i:=p+1 to Length(s) do
if s[i] = ':' then begin if s[i] = ':' then begin
@ -698,9 +708,11 @@ begin
// Seek for "AM/PM" etc to detect that specific format // Seek for "AM/PM" etc to detect that specific format
isAMPM := (pos('AM/PM', s) > 0) or (pos('A/P', s) > 0) or (pos('AMPM', s) > 0); isAMPM := (pos('AM/PM', s) > 0) or (pos('A/P', s) > 0) or (pos('AMPM', s) > 0);
// Look for square brackets indicating the interval format. // Look for special square bracket symbols indicating the interval format.
p := pos('[', s); isInterval := (pos('[H]', s) <> 0) or (pos('[HH]', s) <> 0) or
if p > 0 then isInterval := (pos(']', s) > 0) else isInterval := false; (pos('[M]', s) <> 0) or (pos('[MM]', s) <> 0) or
(pos('[N]', s) <> 0) or (pos('[NN]', s) <> 0) or
(pos('[S]', s) <> 0) or (pos('[SS]', s) <> 0);
// Count decimals // Count decimals
pdp := pos('.', s); pdp := pos('.', s);

View File

@ -182,10 +182,10 @@ begin
for i:=Low(SollDateTimes) to High(SollDateTimes) do begin for i:=Low(SollDateTimes) to High(SollDateTimes) do begin
SollDateTimeStrings[i, 0] := DateToStr(SollDateTimes[i]) + ' ' + FormatDateTime('t', SollDateTimes[i]); SollDateTimeStrings[i, 0] := DateToStr(SollDateTimes[i]) + ' ' + FormatDateTime('t', SollDateTimes[i]);
SollDateTimeStrings[i, 1] := DateToStr(SollDateTimes[i]); SollDateTimeStrings[i, 1] := DateToStr(SollDateTimes[i]);
SollDateTimeStrings[i, 2] := FormatDateTime('t', SollDateTimes[i]); SollDateTimeStrings[i, 2] := FormatDateTime('hh:nn', SollDateTimes[i]);
SolLDateTimeStrings[i, 3] := FormatDateTime('tt', SollDateTimes[i]); SolLDateTimeStrings[i, 3] := FormatDateTime('hh:nn:ss', SollDateTimes[i]);
SollDateTimeStrings[i, 4] := FormatDateTime('t am/pm', SollDateTimes[i]); SollDateTimeStrings[i, 4] := FormatDateTime('hh:nn am/pm', SollDateTimes[i]); // dont't use "t" - it does the hours wrong
SollDateTimeStrings[i, 5] := FormatDateTime('tt am/pm', SollDateTimes[i]); SollDateTimeStrings[i, 5] := FormatDateTime('hh:nn:ss am/pm', SollDateTimes[i]);
SollDateTimeStrings[i, 6] := FormatDateTime('dd/mmm', SollDateTimes[i]); SollDateTimeStrings[i, 6] := FormatDateTime('dd/mmm', SollDateTimes[i]);
SollDateTimeStrings[i, 7] := FormatDateTime('mmm/yy', SollDateTimes[i]); SollDateTimeStrings[i, 7] := FormatDateTime('mmm/yy', SollDateTimes[i]);
SollDateTimeStrings[i, 8] := FormatDateTime('nn:ss', SollDateTimes[i]); SollDateTimeStrings[i, 8] := FormatDateTime('nn:ss', SollDateTimes[i]);
@ -331,7 +331,11 @@ begin
Continue; // The formats nfFmtDateTime and nfTimeInterval are not supported by BIFF2 Continue; // The formats nfFmtDateTime and nfTimeInterval are not supported by BIFF2
MyWorksheet.WriteDateTime(Row, Col, SollDateTimes[Row], SollDateTimeFormats[Col], SollDateTimeFormatStrings[Col]); MyWorksheet.WriteDateTime(Row, Col, SollDateTimes[Row], SollDateTimeFormats[Col], SollDateTimeFormatStrings[Col]);
ActualString := MyWorksheet.ReadAsUTF8Text(Row, Col); ActualString := MyWorksheet.ReadAsUTF8Text(Row, Col);
CheckEquals(SollDateTimeStrings[Row, Col], ActualString, 'Test unsaved string mismatch cell ' + CellNotation(MyWorksheet,Row,Col)); CheckEquals(
Lowercase(SollDateTimeStrings[Row, Col]),
Lowercase(ActualString),
'Test unsaved string mismatch cell ' + CellNotation(MyWorksheet,Row,Col)
);
end; end;
MyWorkBook.WriteToFile(TempFile, AFormat, true); MyWorkBook.WriteToFile(TempFile, AFormat, true);
MyWorkbook.Free; MyWorkbook.Free;
@ -350,7 +354,11 @@ begin
if (AFormat = sfExcel2) and (SollDateTimeFormats[Col] in [nfFmtDateTime, nfTimeInterval]) then if (AFormat = sfExcel2) and (SollDateTimeFormats[Col] in [nfFmtDateTime, nfTimeInterval]) then
Continue; // The formats nfFmtDateTime and nfTimeInterval are not supported by BIFF2 Continue; // The formats nfFmtDateTime and nfTimeInterval are not supported by BIFF2
ActualString := MyWorksheet.ReadAsUTF8Text(Row,Col); ActualString := MyWorksheet.ReadAsUTF8Text(Row,Col);
CheckEquals(SollDateTimeStrings[Row, Col], ActualString, 'Test saved string mismatch cell '+CellNotation(MyWorksheet,Row,Col)); CheckEquals(
Lowercase(SollDateTimeStrings[Row, Col]),
Lowercase(ActualString),
'Test saved string mismatch cell '+CellNotation(MyWorksheet,Row,Col)
);
end; end;
// Finalization // Finalization

View File

@ -348,6 +348,8 @@ type
TsBIFFNumFormatList = class(TsCustomNumFormatList) TsBIFFNumFormatList = class(TsCustomNumFormatList)
protected protected
procedure AddBuiltinFormats; override; procedure AddBuiltinFormats; override;
procedure Analyze(AFormatIndex: Integer; var AFormatString: String;
var ANumFormat: TsNumberFormat; var ADecimals: Word); override;
public public
function FormatStringForWriting(AIndex: Integer): String; override; function FormatStringForWriting(AIndex: Integer): String; override;
end; end;
@ -478,32 +480,6 @@ implementation
uses uses
StrUtils; StrUtils;
const
{ see ➜ 5.49 }
COUNT_DEFAULT_FORMATS = 58;
NOT_USED = nfGeneral;
DEFAULT_NUM_FORMATS: array[1..COUNT_DEFAULT_FORMATS] of TsNumberFormat = (
nfFixed, nfFixed, nfFixedTh, nfFixedTh, nfFixedTh, // 1..5
nfFixedTh, nfFixedTh, nfFixedTh, nfPercentage, nfPercentage, // 6..10
nfExp, NOT_USED, NOT_USED, nfShortDate, nfShortDate, // 11..15
nfFmtDateTime, nfFmtDateTime, nfShortTimeAM, nfLongTimeAM, nfShortTime, // 16..20
nfLongTime, nfShortDateTime, NOT_USED, NOT_USED, NOT_USED, // 21..25
NOT_USED, NOT_USED, NOT_USED, NOT_USED, NOT_USED, // 26..30
NOT_USED, NOT_USED, NOT_USED, NOT_USED, NOT_USED, // 31..35
NOT_USED, nfFixedTh, nfFixedTh, nfFixedTh, nfFixedTh, // 36..40
nfFixedTh, nfFixedTh, nfFixedTh, nfFixedTh, nfFmtDateTime, // 41..45
nfTimeInterval, nfFmtDateTime, nfSci, NOT_USED, NOT_USED, // 46..50
NOT_USED, NOT_USED, NOT_USED, NOT_USED, NOT_USED, // 51..55
NOT_USED, NOT_USED, NOT_USED // 56..58
);
DEFAULT_NUM_FORMAT_DECIMALS: array[1..COUNT_DEFAULT_FORMATS] of word = (
0, 2, 0, 2, 0, 0, 2, 2, 0, 2, // 1..10
2, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 11..20
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 21..30
0, 0, 0, 0, 0, 0, 0, 0, 2, 2, // 31..40
0, 0, 2, 2, 0, 3, 0, 1, 0, 0, // 41..50 #48 is "scientific", use "exponential" instead
0, 0, 0, 0, 0, 0, 0, 0); // 51..58
function ConvertExcelDateTimeToDateTime( function ConvertExcelDateTimeToDateTime(
const AExcelDateNum: Double; ADateMode: TDateMode): TDateTime; const AExcelDateNum: Double; ADateMode: TDateMode): TDateTime;
begin begin
@ -574,17 +550,17 @@ begin
// fraction formats 12 ('# ?/?') and 13 ('# ??/??') not supported // fraction formats 12 ('# ?/?') and 13 ('# ??/??') not supported
AddFormat(14, nfShortDate); AddFormat(14, nfShortDate);
AddFormat(15, nfLongDate); AddFormat(15, nfLongDate);
AddFormat(16, nfFmtDateTime, 'D-MMM'); AddFormat(16, nfFmtDateTime, 'd/mmm');
AddFormat(17, nfFmtDateTime, 'MMM-YY'); AddFormat(17, nfFmtDateTime, 'mmm/yy');
AddFormat(18, nfShortTimeAM); AddFormat(18, nfShortTimeAM);
AddFormat(19, nfLongTimeAM); AddFormat(19, nfLongTimeAM);
AddFormat(20, nfShortTime); AddFormat(20, nfShortTime);
AddFormat(21, nfLongTime); AddFormat(21, nfLongTime);
AddFormat(22, nfShortDateTime); AddFormat(22, nfShortDateTime);
// 23..44 not supported // 23..44 not supported
AddFormat(45, nfFmtDateTime, 'mm:ss'); AddFormat(45, nfFmtDateTime, 'nn:ss');
AddFormat(46, nfTimeInterval, '[h]:mm:ss'); AddFormat(46, nfTimeInterval, '[h]:nn:ss');
AddFormat(47, nfFmtDateTime, 'mm:ss.z'); // z will be replace by 0 later AddFormat(47, nfFmtDateTime, 'nn:ss.z'); // z will be replace by 0 later
AddFormat(48, nfSci, '##0.0E+0', 1); AddFormat(48, nfSci, '##0.0E+0', 1);
// 49 ("Text") not supported // 49 ("Text") not supported
@ -594,6 +570,51 @@ begin
FNextFormatIndex := 164; FNextFormatIndex := 164;
end; end;
{ Considers some Excel specialities for format detection.
The output values will be passed to fpc. }
procedure TsBIFFNumFormatList.Analyze(AFormatIndex: Integer;
var AFormatString: String; var ANumFormat: TsNumberFormat;
var ADecimals: Word);
var
fmt: String;
begin
fmt := Lowercase(AFormatString);
{ Check the built-in formats first }
if (pos('[$-F400]', AFormatString) = 1) then begin
ANumFormat := nfLongTime;
AFormatString := ''; // will be replaced by system's format setting
ADecimals := 0;
exit;
end;
if (pos('[$', fmt) = 1) then begin
if (pos('h:mm:ss\', fmt) > 0) then begin
// long time format
if (pos('am/pm', fmt) > 0) or (pos('a/p',fmt) > 0) then begin
ANumFormat := nfLongTimeAM;
AFormatString := '';
end else begin
ANumFormat := nfLongTime;
AFormatString := '';
end;
ADecimals := 0;
exit;
end;
if (pos('h:mm\', fmt) > 0) then begin
if (pos('am/pm', fmt) > 0) or (pos ('a/p', fmt) > 0) then begin
ANumFormat := nfShortTimeAM;
AFormatString := '';
end else begin
ANumFormat := nfShortTime;
AFormatString := '';
end;
end;
ADecimals := 0;
exit;
end;
inherited Analyze(AFormatIndex, AFormatString, ANumFormat, ADecimals);
end;
{ Creates formatting strings that are written into the file. } { Creates formatting strings that are written into the file. }
function TsBIFFNumFormatList.FormatStringForWriting(AIndex: Integer): String; function TsBIFFNumFormatList.FormatStringForWriting(AIndex: Integer): String;
var var
@ -606,8 +627,12 @@ begin
nfFmtDateTime: nfFmtDateTime:
begin begin
Result := lowercase(item.FormatString); Result := lowercase(item.FormatString);
for i:=1 to Length(Result) do for i:=1 to Length(Result) do begin
// The milliseccond format contains the symbol "z" in fpc, but Excel wants "0"
if Result[i] in ['z', 'Z'] then Result[i] := '0'; if Result[i] in ['z', 'Z'] then Result[i] := '0';
// The minutes in short time formats are coded by "n" in fpc, but Excel wants "m".
if Result[i] in ['n', 'N'] then Result[i] := 'm';
end;
end; end;
nfTimeInterval: nfTimeInterval:
// Time interval format string could still be without square brackets // Time interval format string could still be without square brackets

View File

@ -41,6 +41,20 @@ uses
type type
{ TsOOXMLFormatList }
TsOOXMLNumFormatList = class(TsCustomNumFormatList)
protected
{
procedure AddBuiltinFormats; override;
procedure Analyze(AFormatIndex: Integer; var AFormatString: String;
var ANumFormat: TsNumberFormat; var ADecimals: Word); override;
}
public
{
function FormatStringForWriting(AIndex: Integer): String; override;
}
end;
{ TsSpreadOOXMLWriter } { TsSpreadOOXMLWriter }
TsSpreadOOXMLWriter = class(TsCustomSpreadWriter) TsSpreadOOXMLWriter = class(TsCustomSpreadWriter)
@ -52,22 +66,30 @@ type
FWorkbookString, FWorkbookRelsString, FStylesString, FSharedStrings: string; FWorkbookString, FWorkbookRelsString, FStylesString, FSharedStrings: string;
FSheets: array of string; FSheets: array of string;
FSharedStringsCount: Integer; FSharedStringsCount: Integer;
protected
{ Helper routines }
procedure CreateNumFormatList; override;
protected
{ Streams with the contents of files } { Streams with the contents of files }
FSContentTypes: TStringStream; FSContentTypes: TStringStream;
FSRelsRels: TStringStream; FSRelsRels: TStringStream;
FSWorkbook, FSWorkbookRels, FSStyles, FSSharedStrings: TStringStream; FSWorkbook, FSWorkbookRels, FSStyles, FSSharedStrings: TStringStream;
FSSheets: array of TStringStream; FSSheets: array of TStringStream;
FCurSheetNum: Integer; FCurSheetNum: Integer;
protected
{ Routines to write those files } { Routines to write those files }
procedure WriteGlobalFiles; procedure WriteGlobalFiles;
procedure WriteContent; procedure WriteContent;
procedure WriteWorksheet(CurSheet: TsWorksheet); procedure WriteWorksheet(CurSheet: TsWorksheet);
function GetStyleIndex(ACell: PCell): Cardinal; function GetStyleIndex(ACell: PCell): Cardinal;
protected
{ Record writing methods } { Record writing methods }
//todo: add WriteDate //todo: add WriteDate
procedure WriteLabel(AStream: TStream; const ARow, ACol: Cardinal; const AValue: string; ACell: PCell); override; procedure WriteLabel(AStream: TStream; const ARow, ACol: Cardinal; const AValue: string; ACell: PCell); override;
procedure WriteNumber(AStream: TStream; const ARow, ACol: Cardinal; const AValue: double; ACell: PCell); override; procedure WriteNumber(AStream: TStream; const ARow, ACol: Cardinal; const AValue: double; ACell: PCell); override;
procedure WriteDateTime(AStream: TStream; const ARow, ACol: Cardinal; const AValue: TDateTime; ACell: PCell); override; procedure WriteDateTime(AStream: TStream; const ARow, ACol: Cardinal; const AValue: TDateTime; ACell: PCell); override;
public public
constructor Create(AWorkbook: TsWorkbook); override; constructor Create(AWorkbook: TsWorkbook); override;
destructor Destroy; override; destructor Destroy; override;
@ -114,6 +136,7 @@ const
MIME_STYLES = MIME_SPREADML + '.styles+xml'; MIME_STYLES = MIME_SPREADML + '.styles+xml';
MIME_STRINGS = MIME_SPREADML + '.sharedStrings+xml'; MIME_STRINGS = MIME_SPREADML + '.sharedStrings+xml';
{ TsSpreadOOXMLWriter } { TsSpreadOOXMLWriter }
procedure TsSpreadOOXMLWriter.WriteGlobalFiles; procedure TsSpreadOOXMLWriter.WriteGlobalFiles;
@ -367,6 +390,12 @@ begin
inherited Destroy; inherited Destroy;
end; end;
procedure TsSpreadOOXMLWriter.CreateNumFormatList;
begin
FreeAndNil(FNumFormatList);
FNumFormatList := TsOOXMLNumFormatList.Create;
end;
{ {
Writes a string to a file. Helper convenience method. Writes a string to a file. Helper convenience method.
} }