Riprendo questo topic per segnalare che non è difficile scrivere una macro in VBA per stampare un output formattato per LaTeX.
Ho scoperto questa cosa per la tesi, ed ora riporto qui un semplice esempio di fattura. Ovviamente, la parte TeXnica va curata in un primo momento, la parte di stampa del .tex, attraverso una macro VBA, in un secondo momento. Non dovrebbe essere difficile farla anche in OpenOffice.
Il codice è un continuo manipolare di stringhe:
`Sub CorpoDocumento()
Dim txt As String
Dim row As String
Dim preambolo As String
txt = txt & “\documentclass{article}” & vbNewLine & _
“\usepackage[latin1]{inputenc}” & vbNewLine & _
“\usepackage{siunitx}” & vbNewLine & _
“\sisetup{output-decimal-marker={,}}” & vbNewLine & _
“\title{Fattura del ” & ActiveSheet.Name & “}” & vbNewLine & _
“\begin{document}\sffamily” & vbNewLine & _
“\maketitle” & vbNewLine
Call VisualData(row)
txt = txt & row
txt = txt & “Il totale è = ” & Range(“G21”) & vbNewLine & _
“\end{document}”
Open “C:\Users\Orlando\VBA\test.tex” For Output As #1
Print #1, txt
Close #1
End Sub
Public Sub VisualData(row As String)
Const headTab = “\begin{tabular}{|c|c|c|S|}\hline” & vbNewLine
Const footTab = “\end{tabular}” & vbNewLine
Const inteTab = “Codice & Q.tà & Prezzo & {Prezzo lotto}\\” & _
vbNewLine & “\hline” & vbNewLine
Dim iRow As Integer
iRow = 9
While Cells(iRow, 2).Value <> “”
row = row & Cells(iRow, 2) & “&” & Cells(iRow, 4) & _
“&” & Cells(iRow, 5) & “&” & Cells(iRow, 7) & _
“\\” & vbNewLine & “\hline” & vbNewLine
iRow = iRow + 1
Wend
row = headTab & inteTab & row & footTab & vbNewLine
End Sub`
Questo presuppone un foglio opportunamente impostato:

Ciao,
ansys.