CSV export of databooks

Documents for the development of and with JVx.

CSV export of databooks

Postby Development@SIB » Fri Apr 25, 2014 2:24 pm

If you need a CSV export of a databook, there's already a built-in solution in JVx. Of course, it depends on your databook implementation, whether it's a RemoteDataBook or a MemDataBook, or completely different.

But usually, following snippet will help:
Syntax: [ Download ] [ Hide ]
IFileHandle file;

if (pDataBook instanceof RemoteDataBook)
    AbstractConnection pConnection = ((RemoteDataBook)pDataBook).getDataSource().
    file = (IFileHandle)pConnection.call(pDataBook.getName(), "createCSV",
                                         columnNames, labels, filter,
                                         pDataBook.getSort(), LocaleUtil.getDefault().toString());
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    DataBookCSVExporter.writeCSV(pDataBook, bos,
                                 columnNames, labels, filter, null);
    file = new FileHandle(DataBookCSVExporter.formatCSVFileName(pDataBook.getName()),

ILauncher launcher = ApplicationUtil.getLauncher(pComponent);

if (pShow)
    launcher.saveFileHandle(file, null);

You'll need a databook (pDataBook) and the launcher or a UI component (pComponent). The export of remote databooks is implemented in the remote storage, so simply call the remote method. The export of memory databooks will be done with DataBookCSVExporter.

If you want to create CSV exports of server-side storages, have a look at following project: AESStorageExport.

The project is an extension that allows CSV creation of one or more storages and it supports ZIP creation - with or without password protection.
User avatar
Posts: 312
Joined: Mon Sep 28, 2009 1:54 pm

Return to Documentation