Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I've been looking for something like this (inserting images in tables, and being able to sort rows) for a long time - and finally found what might help; just use pyspread: https://manns.github.io/pyspread/

Here is a quick example:

  • Start pyspread
  • In cell 0:0 (A1) enter 2
  • Select cell 0:1 (B1)
  • From menu, click on Macro / Insert bitmap... and choose your image, open
  • Image is inserted, scaled to cell preserving aspect ratio, left-aligned

pyspread-1.png

  • In cell 1:0 (A2) enter 1
  • In cell 1:1 (B2) enter with quotation marks "test text"
  • Select rows 0 and 1
  • On the toolbar, click Sort descending (up arrow)
  • The rows are re-sorted to 1 first and 2 second, the image remains in the cell it is supposed to:

pyspread-2

Note that pyspread expects Python objects in cells, which is why you have to use quotation marks to enter plain text. Also, we can see the image has been embedded as wx.ImageFromData(... and a base-64 string - although images can also be linked to local files (then it's just wx.Bitmap... and a local filesystem path, http URLs are not accepted, but there is probably a workaround).

Note that when you do re-sorting like this, any formatting of the image cell will be lost (and will be reset to default as on the above image), so in that case, you might want to have another cell elsewhere with a proper format for an image for the table, so you can do Format / Copy format from one cell and Format / Paste format to another cell.

Otherwise, the images scale with the cell size (aspect ratio preserved), and can be aligned as text content is ( left, center or right ):

pyspread-3

Maybe one day we'll be able to do this in calc, too...

I've been looking for something like this (inserting images in tables, and being able to sort rows) for a long time - and finally found what might help; just use pyspread: https://manns.github.io/pyspread/

Here is a quick example:

  • Start pyspread
  • In cell 0:0 (A1) enter 2
  • Select cell 0:1 (B1)
  • From menu, click on Macro / Insert bitmap... and choose your image, open
  • Image is inserted, scaled to cell preserving aspect ratio, left-aligned

pyspread-1.png

  • In cell 1:0 (A2) enter 1
  • In cell 1:1 (B2) enter with quotation marks "test text"
  • Select rows 0 and 1
  • On the toolbar, click Sort descending (up arrow)
  • The rows are re-sorted to 1 first and 2 second, the image remains in the cell it is supposed to:

pyspread-2

Note that pyspread expects Python objects in cells, which is why you have to use quotation marks to enter plain text. Also, we can see the image has been embedded as wx.ImageFromData(... and a base-64 string - although images can also be linked to local files (then it's just wx.Bitmap... and a local filesystem path, http URLs are not accepted, but there is probably a workaround).

Note that when you do re-sorting like this, any formatting of the image cell will be lost (and will be reset to default as on the above image), so in that case, you might want to have another cell elsewhere with a proper format for an image for the table, so you can do Format / Copy format from one cell and Format / Paste format to another cell.

The only problem with pyspread so far is that you cannot format/insert hyperlinks (it supports Pango markup, which is basically HTML, but Pango does not support the anchor tag <a href="...">link text</a>)

Otherwise, the images scale with the cell size (aspect ratio preserved), and can be aligned as text content is ( left, center or right ):

pyspread-3

Maybe one day we'll be able to do this in calc, too...

I've been looking for something like this (inserting images in tables, and being able to sort rows) for a long time - and finally found what might help; just use pyspread: https://manns.github.io/pyspread/

Here is a quick example:

  • Start pyspread
  • In cell 0:0 (A1) enter 2
  • Select cell 0:1 (B1)
  • From menu, click on Macro / Insert bitmap... and choose your image, open
  • Image is inserted, scaled to cell preserving aspect ratio, left-aligned

pyspread-1.png

  • In cell 1:0 (A2) enter 1
  • In cell 1:1 (B2) enter with quotation marks "test text"
  • Select rows 0 and 1
  • On the toolbar, click Sort descending (up arrow)
  • The rows are re-sorted to 1 first and 2 second, the image remains in the cell it is supposed to:

pyspread-2

Note that pyspread expects Python objects in cells, which is why you have to use quotation marks to enter plain text. Also, we can see the image has been embedded as wx.ImageFromData(... and a base-64 string - although images can also be linked to local files (then it's just wx.Bitmap... and a local filesystem path, http URLs are not accepted, but there is probably a workaround).

Note that when you do re-sorting like this, any formatting of the image cell will be lost (and will be reset to default as on the above image), so in that case, you might want to have another cell elsewhere with a proper format for an image for the table, so you can do Format / Copy format from one cell and Format / Paste format to another cell.

The only problem with pyspread so far is that you cannot format/insert hyperlinks (it supports Pango markup, which is basically HTML, but Pango does not support the anchor tag <a href="...">link text</a>) ); also if you save a file and reopen it, it will not show the images because the document is in "safe mode", and then you have to do File / Approve file to have the images show (see https://manns.github.io/pyspread/first_steps.html)

Otherwise, the images scale with the cell size (aspect ratio preserved), and can be aligned as text content is ( left, center or right ):

pyspread-3

Maybe one day we'll be able to do this in calc, too...