Symbolic Link (SYLK)


Symbolic Link is a Microsoft file format typically used to exchange data between applications, specifically spreadsheets. SYLK files conventionally have a .slk suffix. Composed of only displayable ANSI characters, it can be easily created and processed by other applications, such as databases.
Microsoft has never published a SYLK specification. Variants of the format are supported by Multiplan, Microsoft Excel, Microsoft Works, OpenOffice.org, LibreOffice and Gnumeric. The format was introduced in the 1980s and has not evolved since 1986.
A commonly encountered 'occurrence' of the SYLK file happens when a comma-separated value format is saved with an unquoted first field name of 'ID', that is the first two characters match the first two characters of the SYLK file format. Microsoft Excel will then emit misleading error messages relating to the format of the file, such as "The file you are trying to open, 'x.csv', is in a different format than specified by the file extension...".
SYLK is known to cause security issues, as it allows an attacker to run arbitrary code, offers the opportunity to disguise the attack vector under the benign-looking appearance of a CSV file, and is still enabled by default on recent versions of Microsoft Excel.

Limitations

SYLK does not have support for Unicode. Even if a SYLK file is created by an application that supports Unicode, the SYLK file will be encoded in the current system's ANSI code page, not in Unicode. If the application contained characters that were displayable in Unicode but have no code point in the current system's code page, they will be converted to question marks in the SYLK file.
The semicolon is treated as a field separator in SYLK, so cannot be used unescaped in data values. If a character string in the SYLK file is to contain a semicolon then it should be prefixed with another semicolon so the string would appear as e.g., "WIDGET;;AXC1254". MS Excel will strip the first semicolon on import and the data element will appear as "WIDGET;AXC1254".
Each line of a SYLK input file must be no longer than 260 characters. Otherwise, Microsoft Excel will issue an error message and skip loading the overlong line.

Description

Below is the contents of a sample SYLK file:

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

This file, when read by a spreadsheet application that supports SYLK would be displayed like the following:
SYLK files consist of a sequence of records with semicolon-delimited lists of fields. In this file, the record acts as a magic number, identifying the file as a SYLK file, as all SYLK files must start with an record. The field without a value indicates the file was not generated by Microsoft Excel or Microsoft's older spreadsheet application Multiplan. Each record describes one cell in the spreadsheet located at cell . The fields define the raw value of each cell. Strings of text are enclosed in quotation marks. Otherwise, the value is listed without quotes. Dates and times are internally stored as numbers of whole and fractional days since a set epoch and displayed accordingly with custom cell formatting options. The field defines the value of the cell to be the value of an expression. Lastly, the record marks the end of the file. It must be the last record in the file.

Formatting

The record is used to define and apply styles to cells, and records can be used to define shared number formats, along with font information. For example:

ID;P
P;PGeneral
P;P_;;_;;_;;_
P;P_;;_;;_;;_
P;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
F;P2;C2

is rendered similar to the following:
The record's field indicates that the number format in the third and penultimate record is being used, and the record's field applies that format to the second column. Indices of records are zero-indexed, while columns and rows are one-indexed. In this example, the following number formats are defined:
  • , the general number format, which displays the number as it is listed in the file,
  • , a number format that uses thousands separators and no decimal places,
  • , the same number format as but with two decimal places,
  • and, the same number format as but with a dollar sign at the start.
The field of the record defines the widths of a group of columns in characters. For instance, the records and set the widths of the first two columns of a spreadsheet to 20 and 30 characters wide respectively. Likewise, would set the widths of the first five columns to be five characters wide each.
The field of the record defines both the number format and text alignment of a cell, column, row, or spreadsheet. Unlike the record, this field only supports a basic set of number formats. As an example, a record would use the default number format with three digits and center-aligned text.
The following SYLK file:

ID;P
P;PGeneral
C;Y1;X1;K"Row 1 Left Justify"
F;P0;FG0L
C;Y2;X1;K"Row 2 Right Justify"
F;P0;FG0R
C;Y3;X1;K"Total at Center"
F;P0;FG0C
C;Y1;X2;K11
C;Y2;X2;K22
C;Y3;X2;K0;ER1C2+R2C2
F;Y1;X2;FF2L
F;Y2;X2;FF2R
F;Y3;X2;F$2C
F;W1 2 25

would be rendered, ignoring the incorrect column widths, like:
Row 1 Left Justify11.00
Row 2 Right Justify 22.00
Total at Center$33.00

The record can also be used to store font information, in addition to the number format. A cell with a record applied would be rendered using the Cambria font, 12point font, boldface, and green.

Syntax

The basic syntax of a SYLK file is shown below :

SYLK-file = 1*
Record = RecordType * LF

A list of valid record types along with their valid fields is shown below:
; record
; record
; record
; record
  • , the continuous cross-cell display format;
  • , the default number format;
  • , the scientific notation or exponential format;
  • , the fixed decimal point format;
  • , the general number format;
  • , the dollar format, which precedes the number with a dollar sign and uses two decimal places;
  • , the bar graph format, with one asterisk for every unit ;
  • or, the percentage format.
and is the text alignment, and can be one of:
  • , center alignment;
  • , the default alignment;
  • , general alignment, which is left alignment for text and right alignment for numbers;
  • , left alignment;
  • , right alignment;
  • , fill;
  • and, ignored.show grid lines?If absent in the entire file, the default grid lines are shown.show headers?If absent in the entire file, column and row headers are shown.show commas?If present and the cell has a numeric value, group separators are shown.fontThe font of the cell, column, or row in the form: .indexed number formatThe indexed Excel-style cell number format, a zero-indexed number corresponding to which record should be used. For instance, selects the number format defined by the fourth record.rowOne-indexed row number. If present, the,,,,,,,, and fields must all be absent and one or more of the following fields must also be present:,, or.styleA list of characters describing the text formatting, cell borders, and backgrounds of the cell, row, column, or spreadsheet. The following characters are used:
  • , for bottom grid lines;
  • , for boldface;
  • , for italic type;
  • , for left grid lines;
  • , for right grid lines;
  • , for shaded backgrounds;
  • and, for top grid lines.column widthSets the widths of a range of columns in the form , where and are one-indexed column numbers and is the width of the columns in characterscell columnOne-indexed cell column number. If present, the field must be present, the,,,,,,, and fields must all be absent, and one or more of the following fields must also be present:,, or.cell rowOne-indexed cell row number. If present, the field must be present.
; record
; record
; record
; record
; record
; record
; record
; record
Date and time values are stored as a floating point numbers. The whole number part is the number of days after either 1 January 1900 or 1 January 1904. The 1904 date system is only used in older versions of Microsoft Excel on Macintosh systems prior to 2011. The decimal component is the number of seconds divided by 86,400 that have elapsed since 00:00 or 12:00AM.
It is possible to convert serial date values to Unix time by subtracting 25,569 or 24,109, and then multiplying by 86,400. Conversion from Unix time to SYLK time can be done by doing the reverse. However, to be displayed properly, the formatting of the cell must be set to a custom format such as.
Microsoft Excel limits cells in imported SYLK files to 255 characters. LibreOffice does not have this limitation.