Fixes to odf_sheet

I tried using the odf_sheet.pl package to read an Excel file (saved as .odf), but needed to make the following fixes to get it to work:

The table.pl file in the package declares table/2, which my version of swipl (8.0.3 64bits) doesn’t like. In that file, and also in data.pl, I replaced all occurrences of table( with tablea( (Careful to only replace table/2 and table/5 when doing this).

The sheet.pl program doesn’t extract cell annotations if those annotations omit a date and author. To get around this, I added the following extra clause after convert_annotations:

convert_annotation(DOM, annotation('','',Text)) :-
    findall(T, xpath(DOM, 'text:p'(text), T), List),
    atomic_list_concat(List, Text).

Essentially, what this accomplishes is if the existing clause for converting annotations fails (e.g. because there is no date or author in the annotation), then the new clause kicks in and tries to convert just the text of the annotation.

These two fixes seemed to do the job and enabled me to read the spreadsheet cells and their annotations.

cheers,

RdR

Thanks. I think the fix for table/2 in the module export list is more cleanly fixed using (table)/2. Add the convert_annotation/2 clause, except returning an unknown time stamp as 0 to make it still a valid time stamp. Pushed back to the git repo.

Where is the git repo for odf_sheet?

1 Like