libreoffice

最後更新: 2023-12-07

目錄

  • .docx -> .txt
  • CSV -> XLSX
  • gen by php

headless

 

.docx -> .txt

libreoffice --headless --convert-to txt:Text test.docx

CSV -> XLSX

# CSV format: UTF-8(Comma delimited)

libreoffice --headless --convert-to xlsx --infilter=CSV:44,34,76,1 test.csv --outdir /tmp

# CSV Filter Options (CSV:44,34,76,1)

1. Field Separator (ASCII values) # 44 (comma), 59 (semicolon)
2. Text Delimiter # 34 for double quotes and 39 for single quotes
3. Character Set  # 0 (Unknown), 76 (UTF-8), 68 (BIG5 )
4. Line number to start reading    
.....

Gen by php

echo shell_exec("export HOME='/tmp' && /bin/libreoffice --headless --convert-to 'txt:Text (encoded):UTF8' test.docx --outdir /tmp");
echo `cat /tmp/test.txt`;