Documentation
¶
Overview ¶
Package spreadsheet owns the SpreadsheetML (XLSX) conventions shared by datatable exports and imports: cell references, OOXML text escapes and serial dates. It performs no I/O.
Index ¶
- Constants
- func AppendColumn(dst []byte, n int) []byte
- func AppendText(dst []byte, text string) []byte
- func DecodeText(text string) string
- func DisplayNumber(text string) (string, bool)
- func ExactNumber(text string) (string, bool)
- func ParseReference(reference string) (column, row int, ok bool)
- func Serial(wall time.Time) (string, bool)
- func Time(serial float64) (time.Time, bool)
- type Kind
Constants ¶
const ( // MaxRows and MaxColumns are the worksheet dimensions of the format. MaxRows = 1_048_576 MaxColumns = 16_384 // MaxCellUTF16Units is the text length limit of one cell. MaxCellUTF16Units = 32_767 // ExactDigits is the precision spreadsheets store and display exactly. ExactDigits = 15 )
const LocalDateTimeLayout = "2006-01-02T15:04:05.999999999"
LocalDateTimeLayout is the wall-clock text layout of LocalDateTime values.
Variables ¶
This section is empty.
Functions ¶
func AppendColumn ¶
AppendColumn appends the column letters of 1-based index n (1 is A).
func AppendText ¶
AppendText XML-escapes cell text and applies OOXML's _xHHHH_ escape to characters XML cannot carry (C0 controls other than tab/newline and U+FFFE/U+FFFF) and to carriage returns, which XML parsers would normalize. Every literal "_x" prefix is protected, including incomplete sequences: expanding a later character inserts an underscore and could otherwise finish a new escape, for example "_x0000\r" becoming "_x0000_x000D_".
func DecodeText ¶
DecodeText reverses the single-pass OOXML _xHHHH_ escape of stored text. Escaped underscores do not recursively decode a later literal sequence.
func DisplayNumber ¶
DisplayNumber returns the text of a stored double that a spreadsheet shows without rounding: at most ExactDigits significant digits, written without an exponent. ok is false when rounding to ExactDigits would change the stored value, for example a 16-digit identifier or 0.30000000000000004, so an importer reports it instead of silently using a different number.
func ExactNumber ¶
ExactNumber returns the shortest exponent-free text that parses back to the stored double, for floating-point columns that receive the value itself.
func ParseReference ¶
ParseReference returns the 1-based column and row of a reference such as "B3". ok is false for malformed references or references outside a sheet.