APPLICATION INTERCHANGE FILE FORMATS
Simple tutorial for programmers



SYLK - SYmbolic LinK (.slk extension)

I found the following code worked (when the text was saved in a file with an .slk extension) for creating a file with two rows of data and a total row within Excel. I was unable to get it to work with OpenOffice so the application of this code is limited. SYLK resources on the 'net seem limited and much of the following was derived from looking at the output from Excel when a file was saved as a SYLK file (which is why I am at a loss to explain why some of the code is required).

ID;P
C;Y1;X1;K"Row 1"
C;Y2;X1;K"Row 2"
C;Y3;X1;K"Total"
C;Y1;X2;K11
C;Y2;X2;K22
C;Y3;X2;K0;ER1C2+R2C2
E

Instead of absolute cell references for the addition formula you could also use relative addressing by relacing the formula line with: C;Y3;X2;K0;ER[-1]C+R[-2]C

The formula line could also be replaced with the sum function used within Excel: C;Y3;X2;K0;Esum(R[-1]C:R[-2]C). This file has all three types.

Next on my agenda was to add formatting (e.g. dollar signs with 2 decimal places). This requires what appears to be a table of format definitions, and secondly a reference to the definition for either the cell or row/column - see this file or bold lines below:

ID;P
P;PGeneral
P;P_("$"* #,##0.00_)
C;Y1;X1;K"Row 1"
C;Y2;X1;K"Row 2"
C;Y3;X1;K"Total"
C;Y1;X2;K1.1
C;Y2;X2;K2.2
C;Y3;X2;K0;ER1C2+R2C2
F;P1;Y3
E


The P1 is referencing the line number with the format type since P0 references the PGeneral line. Lots of other formatting types are available. The following is from an Excel file:

  • P;PGeneral
  • P;P0
  • P;P0.00
  • P;P#,##0
  • P;P#,##0.00
  • P;P#,##0_);;\(#,##0\)
  • P;P#,##0_);;[Red]\(#,##0\)
  • P;P#,##0.00_);;\(#,##0.00\)
  • P;P#,##0.00_);;[Red]\(#,##0.00\)
  • P;P"$"#,##0_);;\("$"#,##0\)
  • P;P"$"#,##0_);;[Red]\("$"#,##0\)
  • P;P"$"#,##0.00_);;\("$"#,##0.00\)
  • P;P"$"#,##0.00_);;[Red]\("$"#,##0.00\)
  • P;P0%
  • P;P0.00%
  • P;P0.00E+00
  • P;P##0.0E+0
  • P;P#\ ?/?
  • P;P#\ ??/??
  • P;Pm/d/yyyy
  • P;Pd\-mmm\-yy
  • P;Pd\-mmm
  • P;Pmmm\-yy
  • P;Ph:mm\ AM/PM
  • P;Ph:mm:ss\ AM/PM
  • P;Ph:mm
  • P;Ph:mm:ss
  • P;Pm/d/yyyy\ h:mm
  • P;Pmm:ss
  • P;Pmm:ss.0
  • P;P@
  • P;P[h]:mm:ss
  • P;P_("$"* #,##0_);;_("$"* \(#,##0\);;_("$"* "-"_);;_(@_)
  • P;P_(* #,##0_);;_(* \(#,##0\);;_(* "-"_);;_(@_)
  • P;P_("$"* #,##0.00_);;_("$"* \(#,##0.00\);;_("$"* "-"??_);;_(@_)
  • P;P_(* #,##0.00_);;_(* \(#,##0.00\);;_(* "-"??_);;_(@_)


  • To format a cell as bold I had to add a font list and then reference it. See this file or the lines below:

    ID;P
    P;FArial;M200
    P;FArial;M200
    P;FArial;M200
    P;FArial;M200;SB
    P;EArial;M200
    P;EArial;M200;SB
    P;EArial;M200
    C;Y1;X1;K"Row 1"
    C;Y2;X1;K"Row 2"
    C;Y3;X1;K"Total"
    C;Y1;X2;K11
    C;Y2;X2;K22
    C;Y3;X2;K0;ER1C2+R2C2
    F;SDM4
    E

    Instead of making a single cell bold you could replace F;SDM4 make the whole line bold with F;SDM4;R3 or the whole column with F;SDM4;C2

    To right justify a cell I replaced the F;SDM4 line with F;FG0R

    This file contains examples of each of the above.

    Reference sites:

    Home Page