Symbolic Link (SYLK)
Filename extension |
.slk |
---|---|
Internet media type | application/x-sylk |
Developed by | Microsoft |
Symbolic Link (SYLK) 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[1] and Gnumeric. The format was introduced in the 1980s and has not evolved since 1986.[2]
A commonly encountered (and spurious) 'occurrence' of the SYLK file happens when a comma-separated value (CSV) 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 (at least to Office 2016) 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...".[3][4]
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 (2016) versions of Microsoft Excel.[2]
Limitations
[edit]SYLK does not have support for Unicode. Even if a SYLK file is created by an application that supports Unicode (for example Microsoft Excel), 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
[edit]This article needs additional citations for verification. (March 2025) |
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 E
This file, when read by a spreadsheet application that supports SYLK would be displayed like the following:
Row 1 | 11 |
Row 2 | 22 |
Total | 33 |
SYLK files consist of a sequence of records with semicolon-delimited lists of fields. In this file, the ID
record (specifically the ID;
at the start of the file) acts as a magic number, identifying the file as a SYLK file, as all SYLK files must start with an ID
record. The P
field without a value indicates the file was not generated by Microsoft Excel or Microsoft's older spreadsheet application Multiplan. Each C
record describes one cell in the spreadsheet located at cell (X,Y)
(the values of the X
and Y
fields). The K
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 E
field defines the value of the cell to be the value of an expression (equivalent, here, to the more familiar formula =B1+B2
). Lastly, the E
record marks the end of the file. It must be the last record in the file.
Formatting
[edit]The F
record is used to define and apply styles to cells, and P
records can be used to define shared number formats, along with font information. For example:
ID;P P;PGeneral P;P_(* #,##0_);;_(* \-#,##0_);;_(* "-"_);;_(@_) P;P_(* #,##0.00_);;_(* \(#,##0.00\);;_(* "-"??_);;_(@_) P;P_("$"* #,##0.00_);;_("$"* \(#,##0.00\);;_("$"* "-"??_);;_(@_) 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 E
is rendered similar to the following:
Row 1 | 11.00 |
Row 2 | 22.00 |
Total | 33.00 |
The F
record's P2
field indicates that the number format in the third and penultimate P
record is being used, and the record's C2
field applies that format to the second column. Indices of P
records are zero-indexed, while columns and rows are one-indexed. In this example, the following number formats are defined:
P0
, the general number format, which displays the number as it is listed in the file,P1
, a number format that uses thousands separators and no decimal places,P2
(applied to column two), the same number format asP1
but with two decimal places,- and
P3
, the same number format asP2
but with a dollar sign at the start.
The W
field of the F
record defines the widths of a group of columns in characters. For instance, the records F;W1 1 20
and F;W2 2 30
set the widths of the first two columns of a spreadsheet to 20 and 30 characters wide respectively. Likewise, F;W1 5 5
would set the widths of the first five columns to be five characters wide each.
The F
field of the F
record defines both the number format and text alignment of a cell, column, row, or spreadsheet. Unlike the P
record, this field only supports a basic set of number formats. As an example, a F;FD3C
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 E
would be rendered, ignoring the incorrect column widths, like:
Row 1 Left Justify | 11.00 |
Row 2 Right Justify | 22.00 |
Total at Center | $33.00 |
The P
record can also be used to store font information, in addition to the number format. A cell with a P;FCambria;M240;SB;L4
record applied would be rendered using the Cambria font (FCambria
), 12 point font (M240
: the value of the M
field divided by 20 is the font size in points), boldface (SB
), and green (L4
).[5]
Syntax
[edit]This section needs additional citations for verification. (March 2025) |
The basic syntax of a SYLK file is shown below (in the ABNF syntax):
SYLK-file = 1*(Record)
Record = RecordType *(";" Field) LF
A list of valid record types along with their valid fields is shown below:
B
record- A record used to tell the number of rows and columns in a spreadsheet. It is recommended[by whom?] that it comes before the
C
andF
records. Supported fields:
Field Name Description Use X
columns The number of columns in the spreadsheet Mandatory Y
rows The number of rows in the spreadsheet Mandatory
C
record- A record used to describe a cell's contents.
Field Name Description Use C
column reference References another cell by its column number. Optional D
Defines a shared expression. If this field is present, the E
field must also be present.Optional E
expression An expression or formula whose value is the value of the cell Optional G
Defines a shared value. If this field is present, the E
field must be absent and theK
field must be present.Optional H
hidden If present, the cell is hidden. Optional I
inside matrix? If present, the cell is inside a matrix, and the K
andE
fields must be absent.Optional K
value A field whose value is the value of the cell Optional M
matrix expression A matrix expression from cell (X,Y)
to cell(C,R)
. If this field is present, theE
field must be absent.Optional N
not protected? If present, or the N
field is present in theID
record, the cell is not protected. If theID
record does not contain theN
field, this field must be absent.Optional P
protected? If present, or if the N
field is not present in theID
record, the cell is protected. If theID
record contains theN
field, this field must be absent.Optional R
row reference References another cell by its row number. Optional S
shared reference References a shared value ( G
field) or expression (D
field). If present, theD
,E
,G
,K
, andM
fields must all be absent and theR
andC
fields must be present, as theR
andC
fields define the row and column the shared value or expression is copied from.Optional X
column position One-indexed column number of the cell Mandatory Y
row position One-indexed row number of the cell. If this field is omitted, the last defined Y
field's value is used instead.Optional
E
record- A record that marks the end of the file. It must be the last record in the file.
F
record- A record that follows any
P
records and applies the formats described by those records (or fields described by theF
record itself) to the entire spreadsheet or a single cell, column, or row. Supported fields:
Field Name Description Use C
column One-indexed column number. If present, the E
,G
,H
,K
,N
,R
,W
,X
, andY
fields must all be absent and one or more of the following fields must also be present:P
,F
, orS
.Optional D
default format Describes a default format. The form is near-identical to the F
field below. The only difference is that theD
specifiers for the number format and cell alignment are both invalid in this field. If this field is present, theC
,R
,X
, andY
fields must all be absent.Optional E
show formula? If present and the cell's value is defined by an expression or formula, that expression or formula is displayed instead of its value. Optional F
format The cell, row, or column format, taking the form of ⟨ch1⟩⟨digits⟩⟨ch2⟩
.⟨ch1⟩
, the number format (and⟨digits⟩
is the number of decimal digits after the decimal separator), is one of the following:C
, the continuous cross-cell display format;D
, the default number format;E
, the scientific notation or exponential format;F
, the fixed decimal point format;G
, 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 (eg:5
would be*****
);- or
%
, the percentage format.
and
⟨ch2⟩
is the text alignment, and can be one of:C
, center alignment;D
, the default alignment;G
, general alignment, which is left alignment for text and right alignment for numbers;L
, left alignment;R
, right alignment;X
, fill;- and
-
, ignored.
Optional G
show grid lines? If absent in the entire file, the default grid lines are shown. Optional H
show headers? If absent in the entire file, column and row headers are shown. Optional K
show commas? If present and the cell has a numeric value, group separators (commas) are shown. Optional N
font The font of the cell, column, or row in the form: ⟨fontId⟩ ⟨size⟩
.[clarification needed]Optional P
indexed number format The indexed Excel-style cell number format, a zero-indexed number corresponding to which P
record should be used. For instance,P3
selects the number format defined by the fourthP
record.Optional R
row One-indexed row number. If present, the C
,E
,G
,H
,K
,N
,W
,X
, andY
fields must all be absent and one or more of the following fields must also be present:P
,F
, orS
.Optional S
style A list of characters describing the text formatting, cell borders, and backgrounds of the cell, row, column, or spreadsheet. The following characters are used: B
, for bottom grid lines;D
, for boldface;I
, for italic type;L
, for left grid lines;R
, for right grid lines;S
, for shaded backgrounds;- and
T
, for top grid lines.
Optional W
column width Sets the widths of a range of columns in the form ⟨col1⟩⟨col2⟩ ⟨width⟩
, where⟨col1⟩
and⟨col2⟩
are one-indexed column numbers and⟨width⟩
is the width of the columns in charactersOptional X
cell column One-indexed cell column number. If present, the Y
field must be present, theC
,E
,G
,H
,K
,N
,R
, andW
fields must all be absent, and one or more of the following fields must also be present:P
,F
, orS
.Optional Y
cell row One-indexed cell row number. If present, the X
field must be present.Optional
- At least one of the following fields must be present:
C
,D
,E
,G
,H
,K
,P
,R
,W
,X
, orY
. - The
X
andY
fields define cell formats, theR
field defines default row formats, theC
field defines default cell formats, and theD
field sets the default spreadsheet format. ID
record- A header record used to identify the type and creator of a spreadsheet. It must be the first record in the file. Supported fields:
Field Name Description Use E
If present, NE
records are considered redundant.[clarification needed]Optional N
If present, the file uses N
-field-style cell protection, otherwise it usesP
-field-style cell protection.Optional P
program The creator of the file. Can include: CL
, for Microsoft Excel,MP
, for Multiplan (Microsoft)- or no value.
Mandatory
NE
record- A record that links an area on the spreadsheet to another area on an external spreadsheet. Must be placed after any
NU
records. Supported fields:
Field Name Description Use E
destination An expression that defines the target area on the spreadsheet to link the external data Mandatory F
file The name of the file containing the external data Mandatory S
source An expression that defines the source area on the external spreadsheet whose data is being linked Mandatory
NL
record- A record that describes chart external links.[clarification needed]
NN
record- A record used to define named functions, macros, and expressions. It is more efficient[according to whom?] if an
NN
record is defined prior to when its name is first used. Supported fields:
Field Name Description Use E
expression An expression describing the value of the named function, macro, or expression. Mandatory F
If present, the named expression can be used as a function. Optional G
A field whose value is of the form ⟨ch⟩ ⟨ch2⟩
that indicates a runnable, named macro with command key alias.[clarification needed] If this field is present, theK
field must be absent.Optional K
A field whose value is of the form ⟨ch⟩ ⟨ch2⟩
that indicates an ordinary, named expression with unused command aliases.[clarification needed] If this field is present, theG
field must be absent.Optional N
name The name of the function, macro, or expression. Mandatory
NU
record- A record that precedes any
NE
records and describes file name substitutions. Supported fields:
Field Name Description Use F
new file The new file name Mandatory L
old file The old file name Mandatory
O
record- A record that describes spreadsheet options. Supported fields:
Field Name Description Use C
A completion test at the nearest preceding C record.[clarification needed] Optional E
A macro sheet.[clarification needed] This should appear[according to whom?] before the first appearance of a F
orG
field in anNN
record as well as before the firstC
record that uses a macro-only function.Optional G
If present, allows value iteration and circular references. Takes the form ⟨iter⟩ ⟨delta⟩
, where⟨iter⟩
is the maximum number of iterations and⟨delta⟩
is a step test that, if smaller, is present.[clarification needed]Optional L
If present, cell references use the A1
-style. In spite of this, even if present, the SYLK file itself still internally usesR1C1
-style references in expressions.Optional M
If present, cells are manually recalculated. Otherwise, they are automatically recalculated. Optional P
sheet protected? If present, the sheet is protected. Optional V
base date value Indicates the date system used for calculating serial date values. This is either 0
for the 1900 date system or4
for the 1904 date system.[6] See below, after the end of the list of records, for more details.Optional
P
record[5]- A record that describes cell formatting and precedes any
F
records. Supported fields:[clarification needed]
Field Name Description Use E
extended font definition An extended font definition Optional F
font definition An normal font definition Optional L
font color The color of the font. Optional M
font size The font size of the format in 1⁄20 point units Optional P
formatting An Excel-style cell format specification Mandatory S
font style The style of the font Optional
W
record- A record that describes window definitions.[clarification needed]
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 (if the O
record has a V
field with value 0
, indicating the 1900 date system is being used) or 1 January 1904 (if instead this value is 4
, indicating the 1904 date system is in use). The 1904 date system is only used in older versions of Microsoft Excel on Macintosh systems prior to 2011.[6] The decimal component is the number of seconds divided by 86,400 (the number of seconds in a day) that have elapsed since 00:00 or 12:00 AM.
It is possible to convert serial date values to Unix time by subtracting 25,569 or 24,109 (the number of days between 1 January 1970, the Unix epoch, and 1 January 1900 or 1 January 1904 respectively), and then multiplying by 86,400. Conversion from Unix time to SYLK time can be done by doing the reverse (dividing by 86,400 and adding 25,569 or 24,109). However, to be displayed properly, the formatting of the cell must be set to a custom format such as P;Pdd/mm/yyyy\ hh:mm:ss
.
Microsoft Excel limits cells in imported SYLK files to 255 characters. LibreOffice does not have this limitation.[citation needed]
External links
[edit]- Detailed examples can also be found at here
Syntax for SYLK can be found at:
- Microsoft SYLK summary (see also the Abusing the SYLK file format article for some useful information)
- GFF Format Summary: Microsoft SYLK
and at:
Limits related to reading and saving with Excel:
References
[edit]- ^ "LibreOffice Calc - Supported File Formats". 12 November 2016.
- ^ a b Stan Hegt (2019-10-30). "Abusing the SYLK file format". outflank.nl. Retrieved 2019-12-14.
- ^ ""SYLK: File format is not valid" error message when you open file". Retrieved August 18, 2015.
- ^ "Excel CSV import returns an SYLK file format error". 9 January 2012. Retrieved August 18, 2015.
- ^ a b "Excel: SYLK File Format Additional P Record Fields". The Microsoft KnowledgeBase Archive. 2 November 1997. Retrieved 10 March 2025.
- ^ a b French, Ted (8 July 2019). "Serial Number and Serial Date in Excel". Lifewire. Retrieved 9 March 2025.