cvs: peardoc /en/package/fileformats/spreadsheet-excel-writer/spreadsheet-excel-writer-format setnumformat.xml
| From: | Xavier Noguer Gallego | Date: | Wed, 06 Aug 2003 17:09:02 +0000 |
| Subject: | cvs: peardoc /en/package/fileformats/spreadsheet-excel-writer/spreadsheet-excel-writer-format setnumformat.xml | ||
| Groups: | php.pear.doc | ||
| Request: | Send a blank email to pear-doc+get-1204@lists.php.net to get a copy of this message | ||
xnoguer Wed Aug 6 13:09:02 2003 EDT
Modified files:
/peardoc/en/package/fileformats/spreadsheet-excel-writer/spreadsheet-excel-writer-format
setnumformat.xml
Log:
adding table with formats and example
Index: peardoc/en/package/fileformats/spreadsheet-excel-writer/spreadsheet-excel-writer-format/setnumformat.xml diff -u peardoc/en/package/fileformats/spreadsheet-excel-writer/spreadsheet-excel-writer-format/setnumformat.xml:1.1 peardoc/en/package/fileformats/spreadsheet-excel-writer/spreadsheet-excel-writer-format/setnumformat.xml:1.2 --- peardoc/en/package/fileformats/spreadsheet-excel-writer/spreadsheet-excel-writer-format/setnumformat.xml:1.1 Thu Apr 10 19:59:36 2003 +++ peardoc/en/package/fileformats/spreadsheet-excel-writer/spreadsheet-excel-writer-format/setnumformat.xml Wed Aug 6 13:09:02 2003 @@ -1,89 +1,190 @@ -<!-- $Revision: 1.1 $ --> -<refentry id="package.fileformats.spreadsheet-excel-writer.spreadsheet-excel-writer-format.setnumformat"> - <refnamediv> - <refname>Format::setNumFormat</refname> - <refpurpose>Sets the numeric format.</refpurpose> - </refnamediv> - <refsynopsisdiv> - <funcsynopsis> - <funcsynopsisinfo> - require_once "Spreadsheet/Excel/Writer.php"; - </funcsynopsisinfo> - <funcprototype> - <funcdef>void <function>Format::setNumFormat</function></funcdef> - - <paramdef> - integer <parameter>$num_format</parameter> - </paramdef> - - - </funcprototype> - </funcsynopsis> - </refsynopsisdiv> - <refsect1 id="package.fileformats.spreadsheet-excel-writer.spreadsheet-excel-writer-format.setnumformat.desc"> - &title.desc; - <para> - Sets the numeric format. - It can be date, time, currency, etc... - </para> - </refsect1> - - <refsect1 id="package.fileformats.spreadsheet-excel-writer.spreadsheet-excel-writer-format.setnumformat.parameter"> - &title.param; - <para> - <itemizedlist> - - <listitem> - <para> - <parameter>integer $num_format</parameter> - - The numeric format. - </para> - </listitem> - - </itemizedlist> - </para> - </refsect1> - - - - - <refsect1 id="package.fileformats.spreadsheet-excel-writer.spreadsheet-excel-writer-format.setnumformat.note"> - &title.note; - - ¬e.notstatic; - - - - <simpara></simpara> - </refsect1> - - <refsect1 id="package.fileformats.spreadsheet-excel-writer.spreadsheet-excel-writer-format.setnumformat.example"> - &title.example; - <example> - <title>Using <function>setNumFormat</function></title> - <programlisting role="php"> - <![CDATA[ -]]> - </programlisting> - </example> - </refsect1> - </refentry> -<!-- Keep this comment at the end of the file -Local variables: -mode: sgml -sgml-omittag:t -sgml-shorttag:t -sgml-minimize-attributes:nil -sgml-always-quote-attributes:t -sgml-indent-step:1 -sgml-indent-data:t -sgml-parent-document:nil -sgml-default-dtd-file:"../../../../../manual.ced" -sgml-exposed-tags:nil -sgml-local-catalogs:nil -sgml-local-ecat-files:nil -End: -vim600: syn=xml fen fdm=syntax fdl=2 si -vim: et tw=78 syn=sgml -vi: ts=1 sw=1 ---> +<!-- $Revision: 1.2 $ --> +<refentry id="package.fileformats.spreadsheet-excel-writer.spreadsheet-excel-writer-format.setnumformat"> + <refnamediv> + <refname>Format::setNumFormat</refname> + <refpurpose>Sets the numeric format.</refpurpose> + </refnamediv> + <refsynopsisdiv> + <funcsynopsis> + <funcsynopsisinfo> + require_once "Spreadsheet/Excel/Writer.php"; + </funcsynopsisinfo> + <funcprototype> + <funcdef>void <function>Format::setNumFormat</function></funcdef> + + <paramdef> + integer <parameter>$num_format</parameter> + </paramdef> + + </funcprototype> + </funcsynopsis> + </refsynopsisdiv> + <refsect1 id="package.fileformats.spreadsheet-excel-writer.spreadsheet-excel-writer-format.setnumformat.desc"> + &title.desc; + <para> + Sets the numeric format. + It can be date, time, currency, etc... + The following table lists possible values for <parameter>$num_format</parameter> + and the corresponding types that a numeric format expects as arguments. + <table> + <title>Numeric formats and types </title> + <tgroup cols="2"> + <colspec align="left" colname="Value" colwidth="50pt"/> + <colspec align="left" colname="Expected Type" colwidth="50pt"/> + <colspec align="left" colname="Description"/> + <tbody> + <row> + <entry>0</entry> + <entry>Decimal</entry> + <entry>The amount of zeros specifies the amount of digits that will be shown</entry> + </row> + <row> + <entry>0.00</entry> + <entry>Decimal</entry> + <entry>The amount of zeros after the decimal dot specifies the amount of decimal digits that will be shown</entry> + </row> + <row> + <entry>#.##</entry> + <entry>Decimal</entry> + <entry>The amount of sharp signs after the decimal dot specifies the maximum amount of decimal digits that will be shown</entry> + </row> + <row> + <entry>0%</entry> + <entry>Percent</entry> + <entry>The amount of zeros specifies the amount of digits that will be shown.</entry> + </row> + <row> + <entry>0.000%</entry> + <entry>Percent</entry> + <entry>The amount of zeros after the decimal dot specifies the amount of decimal digits that will be shown.</entry> + </row> + <row> + <entry>$#.#;[Red]($#.#)</entry> + <entry>Currency</entry> + <entry>Zeros and sharp signs have the same meaning as in other formats. </entry> + </row> + <row> + <entry>??/??</entry> + <entry>Fraction</entry> + <entry>The amount of question signs in the denominator determines its precision + (maximum amount of digits in the denominator).</entry> + </row> + <row> + <entry># ??/??</entry> + <entry>Fraction</entry> + <entry>A fraction with an integer part. Zeros and sharp signs are used for defining the integer part, + and they have the same meaning as in other formats.</entry> + </row> + <row> + <entry>0.00E+#</entry> + <entry>Scientific</entry> + <entry>In scientific notation base and exponent are formated according to the same rules applied to decimals. + For scientific notation zeros and sharp signs appear to be equivalent.</entry> + </row> + <row> + <entry>D-MMM-YY</entry> + <entry>Date</entry> + <entry>A date represented in the given notation. Month can be a one or two digits month, or a three letter month. + Year can have 2 or 4 digits. The argument to be formated as a date is considered to be the number of days since + December 30 1899 (Excel's day zero). For dates preceding day zero, negative numbers can be used.</entry> + </row> + <row> + <entry>D/M/YYYY h:mm:ss</entry> + <entry>Date/Time</entry> + <entry>A date represented in the given notation. The argument to be formated as a date is considered to be the + number of days since Excel's day zero.</entry> + </row> + <row> + <entry>h:mm:ss AM/PM</entry> + <entry>Time</entry> + <entry>A time represented in the given notation. Be careful, the argument to be formated as a time has to be given in days. + For example an argument of 0.5 would be presented as '12:00:00 PM'.</entry> + </row> + </tbody> + </tgroup> + </table> + </para> + <para> + The information here presented comes from OpenOffice.org's Documentation of the Microsoft Excel File Format (<link url="http://sc.openoffice.org/excelfileformat.pdf">http://sc.openoffice.org/excelfileformat.pdf</link>). + </para> + </refsect1> + + <refsect1 id="package.fileformats.spreadsheet-excel-writer.spreadsheet-excel-writer-format.setnumformat.parameter"> + &title.param; + <para> + <itemizedlist> + + <listitem> + <para> + <parameter>integer $num_format</parameter> - + The numeric format. + </para> + </listitem> + + </itemizedlist> + </para> + </refsect1> + + <refsect1 id="package.fileformats.spreadsheet-excel-writer.spreadsheet-excel-writer-format.setnumformat.note"> + &title.note; + + ¬e.notstatic; + + <simpara></simpara> + </refsect1> + + <refsect1 id="package.fileformats.spreadsheet-excel-writer.spreadsheet-excel-writer-format.setnumformat.example"> + &title.example; + <example> + <title>Using <function>setNumFormat</function></title> + <programlisting role="php"> + <![CDATA[ +require_once 'Spreadsheet/Excel/Writer.php'; + +$workbook = new Spreadsheet_Excel_Writer(); +$worksheet =& $workbook->addWorksheet(); + +// We'll show dates with a three letter month and four digit year format +$date_format =& $workbook->addFormat(); +$date_format->setNumFormat('D-MMM-YYYY'); + +// number of seconds in a day +$seconds_in_a_day = 86400; +// Unix timestamp to Excel date difference in seconds +$ut_to_ed_diff = $seconds_in_a_day * 25569; + +// show Excel's day zero date +$worksheet->write(0, 0, "Excel's day zero"); +$worksheet->write(0, 1, 0, $date_format); + +// show today's date +$now = time(); +$worksheet->write(1, 0, "Today's date:"); +$worksheet->write(1, 1, ($now + $ut_to_ed_diff) / $seconds_in_a_day, $date_format); + +$workbook->send('num_formatting.xls'); +$workbook->close(); +]]> + </programlisting> + </example> + </refsect1> + </refentry> +<!-- Keep this comment at the end of the file +Local variables: +mode: sgml +sgml-omittag:t +sgml-shorttag:t +sgml-minimize-attributes:nil +sgml-always-quote-attributes:t +sgml-indent-step:1 +sgml-indent-data:t +sgml-parent-document:nil +sgml-default-dtd-file:"../../../../../manual.ced" +sgml-exposed-tags:nil +sgml-local-catalogs:nil +sgml-local-ecat-files:nil +End: +vim600: syn=xml fen fdm=syntax fdl=2 si +vim: et tw=78 syn=sgml +vi: ts=1 sw=1 +-->
Index: peardoc/en/package/fileformats/spreadsheet-excel-writer/spreadsheet-excel-writer-format/setnumformat.xml diff -u peardoc/en/package/fileformats/spreadsheet-excel-writer/spreadsheet-excel-writer-format/setnumformat.xml:1.1 peardoc/en/package/fileformats/spreadsheet-excel-writer/spreadsheet-excel-writer-format/setnumformat.xml:1.2 --- peardoc/en/package/fileformats/spreadsheet-excel-writer/spreadsheet-excel-writer-format/setnumformat.xml:1.1 Thu Apr 10 19:59:36 2003 +++ peardoc/en/package/fileformats/spreadsheet-excel-writer/spreadsheet-excel-writer-format/setnumformat.xml Wed Aug 6 13:09:02 2003 @@ -1,89 +1,190 @@ -<!-- $Revision: 1.1 $ --> -<refentry id="package.fileformats.spreadsheet-excel-writer.spreadsheet-excel-writer-format.setnumformat"> - <refnamediv> - <refname>Format::setNumFormat</refname> - <refpurpose>Sets the numeric format.</refpurpose> - </refnamediv> - <refsynopsisdiv> - <funcsynopsis> - <funcsynopsisinfo> - require_once "Spreadsheet/Excel/Writer.php"; - </funcsynopsisinfo> - <funcprototype> - <funcdef>void <function>Format::setNumFormat</function></funcdef> - - <paramdef> - integer <parameter>$num_format</parameter> - </paramdef> - - - </funcprototype> - </funcsynopsis> - </refsynopsisdiv> - <refsect1 id="package.fileformats.spreadsheet-excel-writer.spreadsheet-excel-writer-format.setnumformat.desc"> - &title.desc; - <para> - Sets the numeric format. - It can be date, time, currency, etc... - </para> - </refsect1> - - <refsect1 id="package.fileformats.spreadsheet-excel-writer.spreadsheet-excel-writer-format.setnumformat.parameter"> - &title.param; - <para> - <itemizedlist> - - <listitem> - <para> - <parameter>integer $num_format</parameter> - - The numeric format. - </para> - </listitem> - - </itemizedlist> - </para> - </refsect1> - - - - - <refsect1 id="package.fileformats.spreadsheet-excel-writer.spreadsheet-excel-writer-format.setnumformat.note"> - &title.note; - - ¬e.notstatic; - - - - <simpara></simpara> - </refsect1> - - <refsect1 id="package.fileformats.spreadsheet-excel-writer.spreadsheet-excel-writer-format.setnumformat.example"> - &title.example; - <example> - <title>Using <function>setNumFormat</function></title> - <programlisting role="php"> - <![CDATA[ -]]> - </programlisting> - </example> - </refsect1> - </refentry> -<!-- Keep this comment at the end of the file -Local variables: -mode: sgml -sgml-omittag:t -sgml-shorttag:t -sgml-minimize-attributes:nil -sgml-always-quote-attributes:t -sgml-indent-step:1 -sgml-indent-data:t -sgml-parent-document:nil -sgml-default-dtd-file:"../../../../../manual.ced" -sgml-exposed-tags:nil -sgml-local-catalogs:nil -sgml-local-ecat-files:nil -End: -vim600: syn=xml fen fdm=syntax fdl=2 si -vim: et tw=78 syn=sgml -vi: ts=1 sw=1 ---> +<!-- $Revision: 1.2 $ --> +<refentry id="package.fileformats.spreadsheet-excel-writer.spreadsheet-excel-writer-format.setnumformat"> + <refnamediv> + <refname>Format::setNumFormat</refname> + <refpurpose>Sets the numeric format.</refpurpose> + </refnamediv> + <refsynopsisdiv> + <funcsynopsis> + <funcsynopsisinfo> + require_once "Spreadsheet/Excel/Writer.php"; + </funcsynopsisinfo> + <funcprototype> + <funcdef>void <function>Format::setNumFormat</function></funcdef> + + <paramdef> + integer <parameter>$num_format</parameter> + </paramdef> + + </funcprototype> + </funcsynopsis> + </refsynopsisdiv> + <refsect1 id="package.fileformats.spreadsheet-excel-writer.spreadsheet-excel-writer-format.setnumformat.desc"> + &title.desc; + <para> + Sets the numeric format. + It can be date, time, currency, etc... + The following table lists possible values for <parameter>$num_format</parameter> + and the corresponding types that a numeric format expects as arguments. + <table> + <title>Numeric formats and types </title> + <tgroup cols="2"> + <colspec align="left" colname="Value" colwidth="50pt"/> + <colspec align="left" colname="Expected Type" colwidth="50pt"/> + <colspec align="left" colname="Description"/> + <tbody> + <row> + <entry>0</entry> + <entry>Decimal</entry> + <entry>The amount of zeros specifies the amount of digits that will be shown</entry> + </row> + <row> + <entry>0.00</entry> + <entry>Decimal</entry> + <entry>The amount of zeros after the decimal dot specifies the amount of decimal digits that will be shown</entry> + </row> + <row> + <entry>#.##</entry> + <entry>Decimal</entry> + <entry>The amount of sharp signs after the decimal dot specifies the maximum amount of decimal digits that will be shown</entry> + </row> + <row> + <entry>0%</entry> + <entry>Percent</entry> + <entry>The amount of zeros specifies the amount of digits that will be shown.</entry> + </row> + <row> + <entry>0.000%</entry> + <entry>Percent</entry> + <entry>The amount of zeros after the decimal dot specifies the amount of decimal digits that will be shown.</entry> + </row> + <row> + <entry>$#.#;[Red]($#.#)</entry> + <entry>Currency</entry> + <entry>Zeros and sharp signs have the same meaning as in other formats. </entry> + </row> + <row> + <entry>??/??</entry> + <entry>Fraction</entry> + <entry>The amount of question signs in the denominator determines its precision + (maximum amount of digits in the denominator).</entry> + </row> + <row> + <entry># ??/??</entry> + <entry>Fraction</entry> + <entry>A fraction with an integer part. Zeros and sharp signs are used for defining the integer part, + and they have the same meaning as in other formats.</entry> + </row> + <row> + <entry>0.00E+#</entry> + <entry>Scientific</entry> + <entry>In scientific notation base and exponent are formated according to the same rules applied to decimals. + For scientific notation zeros and sharp signs appear to be equivalent.</entry> + </row> + <row> + <entry>D-MMM-YY</entry> + <entry>Date</entry> + <entry>A date represented in the given notation. Month can be a one or two digits month, or a three letter month. + Year can have 2 or 4 digits. The argument to be formated as a date is considered to be the number of days since + December 30 1899 (Excel's day zero). For dates preceding day zero, negative numbers can be used.</entry> + </row> + <row> + <entry>D/M/YYYY h:mm:ss</entry> + <entry>Date/Time</entry> + <entry>A date represented in the given notation. The argument to be formated as a date is considered to be the + number of days since Excel's day zero.</entry> + </row> + <row> + <entry>h:mm:ss AM/PM</entry> + <entry>Time</entry> + <entry>A time represented in the given notation. Be careful, the argument to be formated as a time has to be given in days. + For example an argument of 0.5 would be presented as '12:00:00 PM'.</entry> + </row> + </tbody> + </tgroup> + </table> + </para> + <para> + The information here presented comes from OpenOffice.org's Documentation of the Microsoft Excel File Format (<link url="http://sc.openoffice.org/excelfileformat.pdf">http://sc.openoffice.org/excelfileformat.pdf</link>). + </para> + </refsect1> + + <refsect1 id="package.fileformats.spreadsheet-excel-writer.spreadsheet-excel-writer-format.setnumformat.parameter"> + &title.param; + <para> + <itemizedlist> + + <listitem> + <para> + <parameter>integer $num_format</parameter> - + The numeric format. + </para> + </listitem> + + </itemizedlist> + </para> + </refsect1> + + <refsect1 id="package.fileformats.spreadsheet-excel-writer.spreadsheet-excel-writer-format.setnumformat.note"> + &title.note; + + ¬e.notstatic; + + <simpara></simpara> + </refsect1> + + <refsect1 id="package.fileformats.spreadsheet-excel-writer.spreadsheet-excel-writer-format.setnumformat.example"> + &title.example; + <example> + <title>Using <function>setNumFormat</function></title> + <programlisting role="php"> + <![CDATA[ +require_once 'Spreadsheet/Excel/Writer.php'; + +$workbook = new Spreadsheet_Excel_Writer(); +$worksheet =& $workbook->addWorksheet(); + +// We'll show dates with a three letter month and four digit year format +$date_format =& $workbook->addFormat(); +$date_format->setNumFormat('D-MMM-YYYY'); + +// number of seconds in a day +$seconds_in_a_day = 86400; +// Unix timestamp to Excel date difference in seconds +$ut_to_ed_diff = $seconds_in_a_day * 25569; + +// show Excel's day zero date +$worksheet->write(0, 0, "Excel's day zero"); +$worksheet->write(0, 1, 0, $date_format); + +// show today's date +$now = time(); +$worksheet->write(1, 0, "Today's date:"); +$worksheet->write(1, 1, ($now + $ut_to_ed_diff) / $seconds_in_a_day, $date_format); + +$workbook->send('num_formatting.xls'); +$workbook->close(); +]]> + </programlisting> + </example> + </refsect1> + </refentry> +<!-- Keep this comment at the end of the file +Local variables: +mode: sgml +sgml-omittag:t +sgml-shorttag:t +sgml-minimize-attributes:nil +sgml-always-quote-attributes:t +sgml-indent-step:1 +sgml-indent-data:t +sgml-parent-document:nil +sgml-default-dtd-file:"../../../../../manual.ced" +sgml-exposed-tags:nil +sgml-local-catalogs:nil +sgml-local-ecat-files:nil +End: +vim600: syn=xml fen fdm=syntax fdl=2 si +vim: et tw=78 syn=sgml +vi: ts=1 sw=1 +-->