-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a way to convert an XLSX/ODS file with formula in to a csv file such that it provides insights in to the formula being used #94
Comments
Add a way to convert an XLSX/ODS file with formula in to a csv file such that it provides insights in to the formula being used(Exper-sten.ods will be used for the purpose of this example.) First I outline a solution with LibreOffice UI and then outline how that solution may be carried out in command line. Solution using LibreOffice UIEnable Macro Recording in LibreOfficeDo Save XLSX/ODS fil as CSV file with the following options.
See screenshot for details Here is a CSV file created with the above procedure: Now repeat step (2) with macro recording enabled
Once the ODS file is saved as CSV, save the macro to your Basic Library at some location. Now inspect the REM ***** BASIC *****
sub Main
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
dim args1(2) as new com.sun.star.beans.PropertyValue
args1(0).Name = "URL"
args1(0).Value = "file:///home/kjambunathan/Downloads/junk/Exper-sten1.csv"
args1(1).Name = "FilterName"
args1(1).Value = "Text - txt - csv (StarCalc)"
args1(2).Name = "FilterOptions"
args1(2).Value = "44,34,76,1,,0,false,true,false,true,false"
dispatcher.executeDispatch(document, ".uno:SaveAs", "", 0, args1())
end sub
Make a note of the
|
The recipe shared here is a slightly expanded version of How do I export and import formulas to CSV? [closed] - Ask LibreOffice. It looks like a reverse process of exporting formulae-embedded CSV -> regular formulae-embedded XLSX/ODS is also possible. Need to figure out whether it is possible via command line, and what the command line options are. |
>> "JK" == Jambunathan K ***@***.***> writes:
# Add a way to convert an XLSX/ODS file with formula in to a csv file such that it provides insights in to the formula being used
([Exper-sten.ods](https://github.com/kjambunathan/org-mode-ox-odt/files/6834283/Exper-sten.ods) will be used for the purpose of this example.)
```
libreofficedev7.2 -convert-to csv:"Text - txt - csv (StarCalc)":44,34,76,1,,0,false,true,false,true,false test.ods
```
Here is the `test.csv` file produced by above command
[test.csv](https://github.com/kjambunathan/org-mode-ox-odt/files/6834321/test.csv)
Thanks, I repeated the steps above (but only for the command line) and can reproduce your results. That is a very interesting approach, I went step further and imported the file into org mode. It requires some manual adjustment, since the concepts are quite different (org table is based on operations entirely on a column represented for example by F&) while scalc and other spreadsheets use a different notation.
Moreover in org-table the if needs, both conditions specified so
The scalc formula
=IF(F4>$K$27,(F4-$K$27)*$AE$3)+MIN($K$27,F4)*$G$3+MIN($K$27,G4)*$H$3+IF(H4>$K$27,(H4-$K$27)*$AE$3)+MIN($K$27,H4)*$I$3+I4*$J$3
Has to be
=if(F&>K27,(F&-K27)*AE3,0)+MIN(K27,F&)*G3+MIN(K27,G4)*H3+IF(H&>K27,(H&-K27)*AE3,0)+MIN(K27,H&)*I3+I&*J3
In org mode
But that cannot be help at the moment I think
|
It could help you deal with a "wall-of-formula-text", and help you get your head around it. The package documentation claims that it should be able to identify what it calls as
Going by that claim it should be able to "group" the formulae that occur in column J at cells J4, J5 etc. But it doesn't. It looks like a bug or an incomplete feature to be. You may find it worthwhile to file a bug against the not-recognised-as-formula-group.txt I thought I will share this with you ... even though it has nothing to do with the ODT exporter as such. |
No. It identifies formula groups.
…On Sun, 18 Jul, 2021, 18:45 Uwe Brauer, ***@***.***> wrote:
thanks a lot, that looks quite interesting. If I understand it correctly,
the package should convert from xlsx to R. (that could be included into
orgmode, for course)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#94 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEXTBKDV7VYXT6OLIUHI6VDTYLHY7ANCNFSM5AQYEVJA>
.
|
The other way around, from CVS-->ods with formulas. I started with
and that I add to change to
and then to export to csv, and then to important to LO, it worked. vsum($1..$2); to =SUM($A1:$B1) I will also asks this on the org-mailing list. Not that I make myself too many illustions. |
Thanks, I attach a zip file with a README file that explains the purpose of each file |
…ToTSV, OptimizeColumnWidth): New * contrib/odt/LibreOffice/src/OrgModeUtilities.bas (OptimizeColumnWidth): Add support for optimizing column width in spreadsheets. (CreateODTFileWithAllFactoryStyles): Create a ODT file with all vanilla LibreOffice styles. In a single shot, one can see the XML representation of all factory styles that LibreOffice ships with. The styles that are of specific interest to the current state of the ODT exporter are: (a) the modern List Styles (b) the table template definition, and its related styles. (ODSExportToFormulaTSV): Export a ODS or other spreadsheet document to TSV file; unlike, the regular "data-only" TSV export, the exported TSV file will have the actual Calc formula in formula cells. (ODSExportToTSV, ODSExportToCSV): Export a ODS or other spreadsheet document to a "data-only" TSV or CSV formats. (ODSDoExportToTSV): Workhorse routine that does the above TSV / CSV conversions. (fnWhichComponent, OptimizeColumnWidthOfSheet, CreateIndexMark) (RepeatText, AnchoringParaText, AddPageNumber) (ApplyTableTemplate, ApplyTableTemplates): Misc. helper functions used in above previous three macro entry points. `ODSExportToTSV' addresses #94 and #235. `CreateODTFileWithAllFactoryStyles' is related to #251 (Upgrading of ODT exporter's default `styles.xml' to the current state of art XML definitions) `OptimizeColumnWidth' fixes #245. With this change, one can accomplish the following: - Deprecate or re-define current ODT deployed list styles `OrgNumberedList', `OrgBulletedList'--these are "legacy" list definitions--to to modern list styles. This in turn /may/ allow one fine-grained control over how lists are indented. See #56 and #79. - New LO-supplied styles `List 1', `List 1 start', `List 1 Cont' and `List 1 End' etc can be used as starting points for paragraph styles that can be used within lists. See #250. - Import fancy table cell definitions used in autoformatting of Tables. See #199. * lisp/ox-ods.el (org-ods-import-spreadsheet-file): New command. Export all sheets of ODS file in to TSV format using the Basic Macro `ODSExportToTSV'. When visiting an `org-mode' file, import the exported TSV files as well. This change addresses #94 and #235. * lisp/ox-odt.el (org-odt-convert-capabilities): Add support for export to TSV format(s) * lisp/ox-odt.el (org-odt-map): New pcase pattern. (org-odt-convert-capabilities): Introduce new options `:lo-export-filter-options' and `:out-file-extension' in conversion rules. These options refine the earlier `%x' format specifier. Revise entry for "odt" to "doc" conversion. Add entry for "ods" to "formula.tsv" and "ods" to "tsv" conversion. (org-odt-convert-processes): Remove the `%x' specifier for in the command line for LibreOffice entry. (org-odt-do-convert): Modified.
Add a way to convert an XLSX/ODS file with formula in to a csv file such that it provides insights in to the formula being used
This issue is filed on behalf of @ouboub
This is a sister bug of Add a command to convert an Org table to xlsx · Issue #10 · kjambunathan/org-mode-ox-odt.
See this thread export org table to other formats (gnumeric or scalc or xlsx)
And also this issue import of xlsx failed in https://hub.stenci.la · Issue #1030 · stencila/stencila
An example
ods
file attached to that file is also attached to this issueExper-sten.ods
The text was updated successfully, but these errors were encountered: