Skip to main content
1-Visitor
December 13, 2021
Solved

Multiple tabs in excel when export

  • December 13, 2021
  • 1 reply
  • 2740 views

Hi,

When we export data, is it possible to dynamically split rows and add them in multiple tabs? Eg: if there are total of 5 lakh rows, I wanted to split them 1 lakh rows in 1st tab and from 100001 to 2lakh rows in 2nd tab and likewise. Is it possible to achieve this use case in ThingWorx?

 

Thanks in advance,

Shalini V.

Best answer by PEHOWE

@svisveswaraiya_285745,

 

If you take the approach of loading the ThingWorx CSV Parser Extension, you can write your own service. Having the extension loaded will allow you to create a Service on a Thing. This service can be designed to meet your needs. 

 

From our conversation I would guess that you have an InfoTable which contains all the information you wish to export. The service would need to have some type of loop to work through the information and create a sub infotable which can then be passed to:

 

 

Resources["CSVParserFunctions"].WriteCSVFile(params);
 

This will create a file for that sub table. You will then need to loop and perform the next segment. 

 

Because you have created a unique service to generate the number of files you need. then the service can be activated by a single button push.

 

HTH

Pehowe

1 reply

17-Peridot
December 14, 2021

@svisvswarai,

The CSV file is defined to be a single Tab in an Excel file. There is no support for multiple tabs in the CSV file. The process you create to export the data from your instance can perform the export multiple times. Each export will create a different CSV file. These files can then be imported into different tabs in excel.

 

1-Visitor
December 14, 2021

Hi @PEHOWE ,

Thanks for your response. 

Could you please guide me how to export multiple times by splitting of data? The user will be clicking the export once and based on rows, can the files be exported multiple times?

17-Peridot
December 14, 2021

@svisveswaraiya_285745,

 

There are multiple options on how to export information out of ThingWorx as a CSV file. There is the Data Export widget which takes a Infotable, and Export File name and creates a file which contains the information in the InfoTable. This approach can only export a single file.

 

For a more complex export into multiple files you can load the "ThingWorx CSV Parser" extension which adds a group of functions. This extension can be downloaded from the same site as ThingWorx was downloaded. One of these functions is WriteCSVFile.

WriteCSVFile

Write a CSV File from an Infotable Data Type Source to a specified ThingWorx Repository 

•Below is the Snipet of the Service with Parameters Explanations:

var params = {
  data: undefined /* INFOTABLE */,
  path: undefined /* STRING */,
  fileRepository: undefined /* THINGNAME */,
  withHeader: undefined /* BOOLEAN */
};

// no return
Resources["CSVParserFunctions"].WriteCSVFile(params);

-data = The infotable source of Data to be used as a content for the CSV file
-path = the name of the CSV File that would be created
-fileRepository = The ThingWorx File Repository in which the CSV File will be stored
-withHeader = has a value of true or false to specify whether the CSV File would have a header as first line and which would be based on the Fields of the Infotable Datashape    

 

If you add the CSV Parser Extension, then you can write a service which builds the info table which represents a single tab in your desired file and export the file. The script can then move on to create the additional files which are required for your design.

 

The other option would be to create your own custom extension which opens up other possible solutions.

 

HTH

Pehowe