About
Shop
LaTeX
Software
Books
Gallery
News
Contact
Blog
Settings
Latest news 2019-11-04: The giveaway of two signed copies of “Quack, quack, quack. Give my hat back!” has closed and the winning entrants have been selected. Thank you to everyone who took part.


2.5.2 Sample XLS File

Most of the examples in this book will use data from either CSV files or SQL tables, but datatooltk can also import from Excel .xls files so there is one sample file, shop.xls, to illustrate this. The shop.xls file has two sheets called “products” and “customers”. The first sheet is shown in Figure 2.8. This has three columns. The second and third columns (“B” and “C”) have been set to a currency format. In addition, the third column contains formulae instead of an explicitly entered number.

Figure 2.8: Sample XLS File (First Sheet)
 
Image of spreadsheet displayed in LibreOffice Calc window. The data displayed is as follows:
Product Price (ex VAT) Price (inc VAT)
Ink cartridge £25.00 £30.00
Mouse mat £12.00 £14.40
USB stick £15.00 £18.00
Pen £2.50 £3.00
The final cell (C5) is selected and the contents show the formula =B5*1.2. End of Image.

The data can be fetched via datatooltk. For example, to fetch the data from the first sheet (“products”):

datatooltk --output products.dbtex --xls shop.xls --sheet products

Or using an arara directive:

% arara: datatooltk: {
% arara: --> output: products.dbtex,
% arara: --> xls: shop.xls,
% arara: --> sheet: products }

The resulting products.dbtex file can be loaded in your document using:

\DTLloaddbtex{\products}{products.dbtex}

You can also import Open Document .ods spreadsheets using a similar method to the above but you need to use --ods instead of --xls.


This book is also available as A4 PDF or 12.8cm x 9.6cm PDF or paperback (ISBN 978-1-909440-07-4).

© 2015 Dickimaw Books. "Dickimaw", "Dickimaw Books" and the Dickimaw parrot logo are trademarks. The Dickimaw parrot was painted by Magdalene Pritchett.

Terms of Use Privacy Policy Cookies Site Map FAQs