summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandmarti1424 <andmarti@gmail.com>2015-08-18 10:07:27 -0300
committerandmarti1424 <andmarti@gmail.com>2015-08-18 10:07:27 -0300
commitd2b69a43c37449d66c01de26fe16e9cdbab8a3c3 (patch)
tree0cc2893be81f90a9833764220e51fea97c55dca6
parent27431e7b3f0b57e3a09256f855d151c5319ac1f7 (diff)
parent8a2232b16703524b05e66adcf3109bb4e9ad3cd7 (diff)
Merge branch 'dev' of https://github.com/andmarti1424/scim into dev
-rw-r--r--files/xlsx/f4.xlsxbin0 -> 5905 bytes
-rw-r--r--files/xlsx/products.xlsxbin0 -> 110289 bytes
-rw-r--r--src/xls.c2
-rw-r--r--src/xlsx.c42
4 files changed, 36 insertions, 8 deletions
diff --git a/files/xlsx/f4.xlsx b/files/xlsx/f4.xlsx
new file mode 100644
index 0000000..bfa98d9
--- /dev/null
+++ b/files/xlsx/f4.xlsx
Binary files differ
diff --git a/files/xlsx/products.xlsx b/files/xlsx/products.xlsx
new file mode 100644
index 0000000..8e5f123
--- /dev/null
+++ b/files/xlsx/products.xlsx
Binary files differ
diff --git a/src/xls.c b/src/xls.c
index 2436485..5422420 100644
--- a/src/xls.c
+++ b/src/xls.c
@@ -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;
}
diff --git a/src/xlsx.c b/src/xlsx.c
index b0b6280..8ba8629 100644
--- a/src/xlsx.c
+++ b/src/xlsx.c
@@ -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 {