Documentation
¶
Index ¶
- Constants
- func DisableDownloadHeaders(h http.Header)
- func EnableDownloadHeaders(h http.Header)
- func GenCSV(tab Table, delimiter, enclosure string, encodingFrom string, detectHead bool) ([]byte, error)
- func GenXLS(tab Table, detectHead bool) ([]byte, error)
- func GenXLSX(tab Table, detectHead bool) ([]byte, error)
- func TrimTrailingFinalNewline(b []byte) []byte
- func WriteAttachment(w http.ResponseWriter, fileName, contentType string, body []byte, ...)
- type Table
Constants ¶
const ( TypeCSV = "csv" TypeXLS = "xls" TypeXLSX = "xlsx" )
Export format constants (aligned with Mapbender FOM ExportResponse).
const ( XLSIntType = 0x203 XLSStringType = 0x204 )
BIFF cell record types (Mapbender / legacy Excel writer).
const ( ContentTypeCSV = "text/csv;charset=UTF-16LE" ContentTypeXLS = "application/vnd.ms-excel" ContentTypeXLSX = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" )
Content types aligned with Mapbender ExportResponse::setType.
Variables ¶
This section is empty.
Functions ¶
func DisableDownloadHeaders ¶
DisableDownloadHeaders removes the download-related cache headers.
func EnableDownloadHeaders ¶
EnableDownloadHeaders sets Cache-Control / Pragma / Expires like Mapbender enableDownload().
func GenCSV ¶
func GenCSV(tab Table, delimiter, enclosure string, encodingFrom string, detectHead bool) ([]byte, error)
GenCSV builds UTF-16LE CSV bytes with BOM and a leading sep= line, matching Mapbender ExportResponse::setCsv. Row cells must be UTF-8; encodingFrom is reserved for future transcoding (only UTF-8 is supported today).
func GenXLS ¶
GenXLS generates a legacy .xls (BIFF) workbook matching Mapbender ExportResponse::genXLS layout on little-endian hosts (PHP pack "s" / "d").
func GenXLSX ¶
GenXLSX builds an .xlsx workbook (OpenXML) from tabular data, analogous to Mapbender's SimpleXLSXGen::fromArray.
func TrimTrailingFinalNewline ¶
TrimTrailingFinalNewline removes a single trailing newline from UTF-16LE CSV bytes (after BOM) if present. Mapbender stream ends without extra newline after last row in some paths; callers rarely need this.
func WriteAttachment ¶
func WriteAttachment(w http.ResponseWriter, fileName, contentType string, body []byte, enableDownload bool)
WriteAttachment writes body with Content-Type, Content-Disposition, Content-Length, and optional download headers (Mapbender ExportResponse behavior).