diff options
author | andmarti1424 <andmarti@gmail.com> | 2015-08-18 10:07:27 -0300 |
---|---|---|
committer | andmarti1424 <andmarti@gmail.com> | 2015-08-18 10:07:27 -0300 |
commit | d2b69a43c37449d66c01de26fe16e9cdbab8a3c3 (patch) | |
tree | 0cc2893be81f90a9833764220e51fea97c55dca6 | |
parent | 27431e7b3f0b57e3a09256f855d151c5319ac1f7 (diff) | |
parent | 8a2232b16703524b05e66adcf3109bb4e9ad3cd7 (diff) |
Merge branch 'dev' of https://github.com/andmarti1424/scim into dev
-rw-r--r-- | files/xlsx/f4.xlsx | bin | 0 -> 5905 bytes | |||
-rw-r--r-- | files/xlsx/products.xlsx | bin | 0 -> 110289 bytes | |||
-rw-r--r-- | src/xls.c | 2 | ||||
-rw-r--r-- | src/xlsx.c | 42 |
4 files changed, 36 insertions, 8 deletions
diff --git a/files/xlsx/f4.xlsx b/files/xlsx/f4.xlsx Binary files differnew file mode 100644 index 0000000..bfa98d9 --- /dev/null +++ b/files/xlsx/f4.xlsx diff --git a/files/xlsx/products.xlsx b/files/xlsx/products.xlsx Binary files differnew file mode 100644 index 0000000..8e5f123 --- /dev/null +++ b/files/xlsx/products.xlsx @@ -48,7 +48,7 @@ int open_xls(char * fname, char * encoding) { struct ent * n; if (pWB == NULL) { - error("Error loading %s", fname); + scerror("Error loading %s", fname); return -1; } @@ -29,9 +29,31 @@ // note that 0 is the first string. char * get_xlsx_string(xmlDocPtr doc, int pos) { xmlNode * cur_node = xmlDocGetRootElement(doc)->xmlChildrenNode; + xmlNode * father; + char * result = NULL; while (pos--) cur_node = cur_node->next; - cur_node = cur_node->xmlChildrenNode; return (char *) cur_node->xmlChildrenNode->content; + + father = cur_node; + cur_node = father->xmlChildrenNode; + + while (father != NULL) { // recorro hijos + while (cur_node != NULL) { // recorro hermanos + //scdebug("%s", cur_node->name); + if ( ! xmlStrcmp(cur_node->name, (const xmlChar *) "t") ) { + result = (char *) cur_node->xmlChildrenNode->content; + //scdebug("FOUND: %s", result); + break; + } + cur_node = cur_node->next; + } + + if (result != NULL) break; + father = father->xmlChildrenNode; + if (father != NULL) cur_node = father->xmlChildrenNode; + } + + return result; } // this functions takes the DOM of the styles file @@ -112,16 +134,22 @@ void get_sheet_data(xmlDocPtr doc, xmlDocPtr doc_strings, xmlDocPtr doc_styles) // string if ( s != NULL && ! strcmp(s, "s") ) { char * strvalue = get_xlsx_string(doc_strings, atoi((char *) child_node->xmlChildrenNode->xmlChildrenNode->content)); - clean_carrier(strvalue); // we handle padding - sprintf(line_interp, "label %s%d=\"%s\"", coltoa(c), r, strvalue); - send_to_interp(line_interp); + if (strvalue != NULL && strvalue[0] != '\0') { + strvalue = str_replace (strvalue, "\"", "''"); + clean_carrier(strvalue); // we handle padding + sprintf(line_interp, "label %s%d=\"%s\"", coltoa(c), r, strvalue); + send_to_interp(line_interp); + } // inlinestring } else if ( s != NULL && ! strcmp(s, "inlineStr") ) { char * strvalue = (char *) child_node->xmlChildrenNode->xmlChildrenNode->xmlChildrenNode->content; - clean_carrier(strvalue); // we handle padding - sprintf(line_interp, "label %s%d=\"%s\"", coltoa(c), r, strvalue); - send_to_interp(line_interp); + if (strvalue != NULL && strvalue[0] != '\0') { + strvalue = str_replace (strvalue, "\"", "''"); + clean_carrier(strvalue); // we handle padding + sprintf(line_interp, "label %s%d=\"%s\"", coltoa(c), r, strvalue); + send_to_interp(line_interp); + } // numbers (can be dates, results from formulas or simple numbers) } else { |