Focal Point
[SOLVED] Excel and leading zeros

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/413101254

May 27, 2010, 02:58 PM
Luminita
[SOLVED] Excel and leading zeros
Hi,
The output of my report is Excel and in order to format it for printing (landscape, borders, etc) I used the HTMLFORM approach (trying to steer away from templates...). One of my output columns is strings, but some values can be numbers only, for example 001234. If I just output to Excel (ON TABLE PCHOLD FORMAT EXL2K) everything looks ok, the leading zeros appear. Once I change to output to use the HTMLFORM, the leading zeros are dropped.

Any ideas of how I can make sure I get those zeros?
Thanks,
Luminita

Here is the HTMLFORM code I use.
 -HTMLFORM BEGIN
<html xmlns:o="urn:schemas-microsoft-com:office:office"
 xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">
 <head>
 <meta http-equiv=Content-Type content="text/html;">
 <meta name=ProgId content=Excel.Sheet>
 <meta name=Generator content="Microsoft Excel 10">
 <!--[if gte mso 9]><xml>
  <o:OfficeDocumentSettings>
-*  <o:ReadOnlyRecommended/>
  <o:DownloadComponents/>
  <o:LocationOfComponents HRef=3D"file:///\\"/>
  </o:OfficeDocumentSettings>
 </xml><![endif]-->
<style>
<!--table
	{
	mso-displayed-decimal-separator:"\x";
	mso-number-format:"\.00";
	mso-displayed-thousand-separator:"\,";}
@page
	{mso-footer-data : '&|L Date: &|D Time: &|T &|C Fidelity Confidential Information &|R Page &|P of &|N';
	margin:.5in .25in .5in .25in;
	mso-header-margin:.25in;
	mso-footer-margin:.25in;
	mso-page-orientation:landscape;
	mso-horizontal-page-align:center; padding-top:0px;
	mso-number-format:"\#\#\,\#\#0\.00";}
-->
	</style>
<!--[if gte mso 9]><xml>
 <x:ExcelWorkbook>
  <x:ExcelWorksheets>
   <x:ExcelWorksheet>
    <x:Name>ExceptionReport</x:Name>
    <x:WorksheetOptions>
    <x:FitToPage/>
     <x:Print>
           <x:FitWidth>1</x:FitWidth>
           <x:FitHeight>99</x:FitHeight>
      <x:ValidPrinterInfo/>
      <x:Scale>80</x:Scale>
      <x:HorizontalResolution>600</x:HorizontalResolution>
      <x:VerticalResolution>600</x:VerticalResolution>
    </x:Print>
    <x:PageBreakZoom>100</x:PageBreakZoom>
     <x:Panes>
      <x:Pane>
       <x:Number>3</x:Number>
      </x:Pane>
     </x:Panes>
     <x:ProtectContents>False</x:ProtectContents>
    </x:WorksheetOptions>
-*    <x:PageBreaks>
-*     <x:RowBreaks>0</x:RowBreaks>
-*    </x:PageBreaks>
   </x:ExcelWorksheet>
  </x:ExcelWorksheets>
  <x:AcceptLabelsInFormulas/>
 <x:WindowHeight>11535</x:WindowHeight>
 <x:WindowWidth>19140</x:WindowWidth>
 <x:WindowTopX>120</x:WindowTopX>
 <x:WindowTopY>120</x:WindowTopY>
 </x:ExcelWorkbook>
-* <Styles>
-*	   <Style ss:ID="A">
-*	     <NumberFormat ss:Format="@" />
-*	   <Style>
-* <Styles>
 <x:SupBook>
   <x:Path>ExceptionReport</x:Path>
   <x:SheetName>ExceptionReport</x:SheetName>
  </x:SupBook>
</xml>
</head>
!IBI.FIL.NTF_OUT;
-HTMLFORM END
 

This message has been edited. Last edited by: Luminita,


7.6.6 on AIX platform
Output: variety (Excel, HTML and PDF)
May 27, 2010, 03:26 PM
Francis Mariani
I've never seen code like this used inside an HTMLFORM. How did you come up with this?

Since you're using this type of code, can't you address a specific column and use styling to change the number format? Or is the number format code (NumberFormat ss:Format="@") removing the leading zeros?


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
May 28, 2010, 03:06 AM
Ram Prasad E
Hope this helps.
DEFINE FILE CAR
DEF_COL_A/A20=IF COUNTRY EQ 'ENGLAND' THEN '001234' ELSE IF COUNTRY EQ 'ITALY' THEN '004231' ELSE '12346687';
END
TABLE FILE CAR
PRINT
DEF_COL_A
COMPUTE COM_COL_A/A20=IF COUNTRY EQ 'ENGLAND' THEN '001234 ' ELSE IF COUNTRY EQ 'ITALY' THEN '004231 ' ELSE '12346687 ';
CAR
COUNTRY
ON TABLE HOLD AS HLD_1 FORMAT HTMTABLE
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
TYPE=DATA,COLUMN=N1,CLASS=NUMASTEXT,$
TYPE=DATA,COLUMN=N2,CLASS=NUMASNUM,$
ENDSTYLE
END


SET HTMLFORMTYPE=XLS
-HTMLFORM BEGIN
<html xmlns:o="urn:schemas-microsoft-com:office:office"
 xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">
 <head>
 <meta http-equiv=Content-Type content="text/html;">
 <meta name=ProgId content=Excel.Sheet>
 <meta name=Generator content="Microsoft Excel 10">
<style>
TD.NUMASTEXT
{mso-number-format:\@}
TD.NUMASNUM
{mso-number-format:\#\,\#\#0\.00}
</style>
</head>
<body>
<table>
<tr>
<td class="accountnum">
!IBI.FIL.HLD_1;
</td>
</tr></table>
</body>
-HTMLFORM END



WebFOCUS 8.1.05
Windows
http://ibiwebfocus.wordpress.com
https://www.facebook.com/groups/ibi.webfocus/
May 28, 2010, 09:57 AM
Luminita
Prasad, Thank you so much, that worked like a charm! I am having a hard time finding help documents for stuff like this, any tips or tricks on how to go about that?


Francis, I sort of "inherited" this code from other developers, and have been tweaking it to suit my needs. It's a good alternative to using the Excel templates.

Thank you!
Luminita


7.6.6 on AIX platform
Output: variety (Excel, HTML and PDF)
May 28, 2010, 11:11 AM
ABT
quote:
s, I sort of "inherited" this code from other developers, and have been


@Francis,
That's the type of code that Excel (and other MS Office docs) uses under the covers. I believe specifically if it is an "online" file.

To see this in action:
1. Open Excel.
2. Create a new Spreadsheet.
3. Populate with data (or don't).
4. Save as file type HTML.
5. Close Excel.
6. Open output in a text editor (suggest TextPad).
7. Bask in the glory of the Office-ified HTML/XML.


------------------------------------
WF Environment:
------------------------------------
Server/Client, ReportCaster, Dev Studio: 7.6.11
Resource Analyzer, Resource Governor, Library, Maintain, InfoAssist
OS: Windows Server 2003
Application/Web Server: Tomcat 5.5.25
Java: JDK 1.6.0_03
Authentication: LDAP, MRREALM Driver
Output: PDF, EXL2K, HTM

------------------------------------
Databases:
------------------------------------
Oracle 10g
DB2 (AS/400)
MSSQL Server 2005
Access/FoxPro
May 31, 2010, 11:03 AM
Francis Mariani
ABT, thanks for that info. At least it appears my assumption is correct regarding the Excel styling. It seems that this type of code would be hard to maintain...


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server