A LibreOffice Calc function to return a basic table editor script from a range of cells

JohnColeman edited this page Sep 28, 2017 · 2 revisions

I have developed a simple workaround for those who would like to embed spreadsheet ranges in Zim as an editable table rather than as an image (with or without a link to an external spreadsheet). It involves Zim's Table Editor plugin, and defining a LibreOffice function via Tools/Macros/Edit Macros:

 Function RangeToZim(pArray()) as String
     Dim i as Long
     Dim j as Long
     Dim rText as String
     rText = ""
     For i = Lbound(pArray()) to Ubound(pArray())
         rText = rText +"|"
         For j = Lbound(pArray(),2) to Ubound(pArray(),2)
             rText = rText & pArray(i,j) & "|"
             Next j
         rText = rText + chr(10)
     Next i
     rText = rText + chr(10)
     RangeToZim = rText
 End Function REM RangeToZim

Then a simple formula like *=RANGETOZIM(A1:C4)*returns a result like:

|column1|column2|count|
|value1|value2|2|
|value3|value4|2|
|value5|value6|2|

Which should be copied and Paste Only as Text for embedding in Zim. Don't forget to CTRL+R to render the Table Editor widget.

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.