Knowledge Base

Preserving for the future: Shell scripts, AoC, and more

Insert filename in Libreoffice Calc spreadsheet ods file in Linux

In LibreOffice Writer, you can use the "Insert Field" tool to easily insert the filename into the document. In Calc, it's a little different, but still possible. You can access the raw filename and sheet with CELL("filename"). To make it pretty, use a longer formula.

=LEFT(REPLACE(LEFT(CELL("filename"),FIND("'",CELL("filename"),2)),1,9,"/"),LEN(REPLACE(LEFT(CELL("filename"),FIND("'",CELL("filename"),2)),1,9,"/"))-1)

References

  1. https://listarchives.libreoffice.org/global/users/msg24734.html
  2. search libreoffice calc insert filename

Comments