1 /* 2 * libxlsxwriter 3 * 4 * Copyright 2014-2016, John McNamara, jmcnamara@cpan.org. See LICENSE.txt. 5 * 6 * common - Common functions and defines for the libxlsxwriter library. 7 * 8 */ 9 module xlsxwriter.common; 10 11 extern(C): 12 13 /* enum lxw_boolean { */ 14 /* LXW_FALSE, */ 15 /* LXW_TRUE */ 16 /* }; */ 17 18 enum LXW_SHEETNAME_MAX = 32; 19 enum LXW_SHEETNAME_LEN = 65; 20 enum LXW_UINT32_T_LEN = 11; /* Length of 4294967296\0. */ 21 enum LXW_IGNORE = 1; 22 enum FILENAME_LEN = 128; 23 enum LXW_NO_ERROR = 0; 24 25 enum lxw_error { 26 LXW_NO_ERROR, // No error. 27 LXW_ERROR_MEMORY_MALLOC_FAILED, // Memory error, failed to malloc() required memory. 28 LXW_ERROR_CREATING_XLSX_FILE, // Error creating output xlsx file. Usually a permissions error. 29 LXW_ERROR_CREATING_TMPFILE, // Error encountered when creating a tmpfile during file assembly. 30 LXW_ERROR_ZIP_FILE_OPERATION, // Zlib error with a file operation while creating xlsx file. 31 LXW_ERROR_ZIP_FILE_ADD, // Zlib error when adding sub file to xlsx file. 32 LXW_ERROR_ZIP_CLOSE, // Zlib error when closing xlsx file. 33 LXW_ERROR_NULL_PARAMETER_IGNORED, // NULL function parameter ignored. 34 LXW_ERROR_PARAMETER_VALIDATION, // Function parameter validation error. 35 LXW_ERROR_MAX_STRING_LENGTH_EXCEEDED, // String exceeds Excel's limit of 32,767 characters. 36 LXW_ERROR_128_STRING_LENGTH_EXCEEDED, // Parameter exceeds Excel's limit of 128 characters. 37 LXW_ERROR_255_STRING_LENGTH_EXCEEDED, // Parameter exceeds Excel's limit of 255 characters. 38 LXW_ERROR_SHARED_STRING_INDEX_NOT_FOUND, // Error finding internal string index. 39 LXW_ERROR_WORKSHEET_INDEX_OUT_OF_RANGE, // Worksheet row or column index out of range. 40 LXW_ERROR_WORKSHEET_MAX_NUMBER_URLS_EXCEEDED, // Maximum number of worksheet URLs (65530) exceeded. 41 LXW_ERROR_IMAGE_DIMENSIONS, // Couldn't read image dimensions or DPI. 42 } 43 44 alias lxw_row_t = uint; 45 alias lxw_col_t = ushort; 46 47 string standaloneEnums(alias enumName)() 48 { 49 import std.traits : EnumMembers; 50 enum e = __traits(identifier, enumName); 51 52 import std.algorithm : map; 53 import std..string : format, join; 54 return [EnumMembers!enumName].map!(m => "enum %s = %s.%s;".format(m, e, m)).join(); 55 }