# Export a table to a file

**URL:** <https://scilab.discourse.group/t/export-a-table-to-a-file/855>\
**Category:** Data handling\
**Created:** [March 8, 2025, 7:57pm UTC](https://scilab.discourse.group/t/export-a-table-to-a-file/855 "2025-03-08T19:57:34Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![mottelet](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/mottelet/32/13_2.png) [@mottelet](https://scilab.discourse.group/u/mottelet)\
**Post date:** [March 10, 2025, 9:17am UTC](https://scilab.discourse.group/t/export-a-table-to-a-file/855/3 "2025-03-10T09:17:50Z")

</div>

Hello Philipp,

For this kind of stuff, a possible way to go is to use LaTeX and the `tabular` environment. Here is a small example:

```auto
t = table(rand(5,3,"normal"), ...
    "VariableNames",["var1Name","var2Name","myLongVarName"])

[n,m] = size(t);
head = strcat("\bf "+t.props.VariableNames,"&") + "\\"
data = strcat(strcat(string(t),"&","c"),"\\")
str = [ sprintf("\\sf\\begin{tabular}{%s}",strcat("r"(ones(1,m)),"|"))
        head; "\hline"; data; "\end{tabular}" ];

h = xstringb(0,0,strcat(str,ascii(10)),1,1,"fill");
h.interpreter = "latex";
xs2pdf(gcf(),"table.pdf")

```

Here is the output in a Scilab figure (the pdf looks strictly the same):  
 ![table](https://global.discourse-cdn.com/free1/uploads/utc/original/1X/43d7e05da73b204b3360154d03062b9b9021d08a.svg)

---

_[View the full topic](https://scilab.discourse.group/t/export-a-table-to-a-file/855)._
