cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

Export DataExport specify name of file ?

fgrondin
5-Regular Member

Export DataExport specify name of file ?

Hey all,

1-

     When using the thing DataExport to export a data table, is there a way to specify the name of the exported file ?

     As of now it only creates file with the name : "Export+DateTime".xlsx

     Is there a way I could use a custom name like "VendingMachineData.xlsx" ?

2-

     Is there a way to get only the file name upon ExportInfoTableAsExcel ?

     I guess I could write down a service that get the name starting from the last "/"

Frederik

1 ACCEPTED SOLUTION

Accepted Solutions
fgrondin
5-Regular Member
(To:posipova)

Ok,

I found a work around to name the export file, but I don't think it's a "good" work around because I'm hard coding stuff,

So basically, I have a textbox, which the user set a name for the file.

Then, when the user click on export data, the service ExportInfotableAsExcel will be call, and then the service renameFile will be call on serviceCompleted.

The path in renameFile is hardcoded since the ExportInfotableAsExcel export the file in a static folder.

So, I just right down /nameofFile.xlsx and rename it right away.

View solution in original post

17 REPLIES 17
posipova
20-Turquoise
(To:fgrondin)

1. Currently cannot specify the export name.

2. Could you please clarify the question? I.e desired result vs current?

fgrondin
5-Regular Member
(To:posipova)

When using the service "ExportInfotableAsExcel" the result of that is the path of where it'll be stored at (repository\DataExporterRepository\Export2017-03-01_16-55-24.xlsx).

And in that result, there is the name of that file which is Export2017-03-01_16-55-24.xslx

Is there a way to get only the name of the file with the extension (.xlsx) ?

Like I said the only way I can figure out how to do it right now would be to write down a script that remove the other stuff.

So basically, I would want the name of the file when it's created, so I can filter the grid that contains the data from FileRepository.GetFileListingWithLinks
in order to get only that file in the grid.

posipova
20-Turquoise
(To:fgrondin)

These is how those services work and they are not editable. Your approach would probably make the most sense for that situation. You may either remove the text prior to \Export.. or perhaps have a variable/counter/prime key to keep track of the exported files.

fgrondin
5-Regular Member
(To:posipova)

Ok,

I found a work around to name the export file, but I don't think it's a "good" work around because I'm hard coding stuff,

So basically, I have a textbox, which the user set a name for the file.

Then, when the user click on export data, the service ExportInfotableAsExcel will be call, and then the service renameFile will be call on serviceCompleted.

The path in renameFile is hardcoded since the ExportInfotableAsExcel export the file in a static folder.

So, I just right down /nameofFile.xlsx and rename it right away.

dsodling
5-Regular Member
(To:fgrondin)

I'm trying to do a similar thing (saving the file with a custom and in my case dynamic filename).

Would you consider sharing the service you wrote? I'm pretty new to this stuff so a look at som code that shows how to get hold of the file etc. would really be a big help.

Best regards

Daniel Södling

fgrondin
5-Regular Member
(To:dsodling)

Hey,

All the services that I'm using are from the extension.

The sad thing though is, even if you can rename it, the data that will be stored in your file, by using the service ExportAs... , will be wrong (just a quick heads up).

First, you will have to create a new Thing and use the FileRepository Thing Template.

In your mashup, you will need to add, in the Data section, the thing you have just created.

In that, you will need to add the service GetFileListingWithLinks and RenameFile.

That RenameFile has 3 parameters:  the name (new name), the path (where the file is stored) and overwrite(remove data or not).

Essentially, you would only need the renameFile service if you already have the file.



fgrondin
5-Regular Member
(To:posipova)

By the way, I have another question about exporting data.

I have 5 DataTable and I would like to export them all into 1 file.

On what I've seen, I can only export 1 Data Table per file.

Is there any way or work around that I could have all 5 data table into 1 file ?

posipova
20-Turquoise
(To:fgrondin)

You can tag them and export to file per Model Tag:

fgrondin
5-Regular Member
(To:posipova)

Forgot to mention that the export functionality that I'm looking is from a mashup, where the user click on a button, then it would get all 5 data table (result from a store procedure) and export all that data into 1 file.

So in the File there would be 5 table next to each others showing all the result,

posipova
20-Turquoise
(To:fgrondin)

You can sniff/use dev tools to see the call for the model tag export and create a service you would call from the mashup using that button.

fgrondin
5-Regular Member
(To:posipova)

Can you give me a bit more information about how I would do it, because I've never done any of that method . Is it a external software I need to do that or what ?

posipova
20-Turquoise
(To:fgrondin)

It's just your browser developer tools, for example if you use Chrome, you can hit F12. Are you familiar with the REST API calls?

fgrondin
5-Regular Member
(To:posipova)

I didn't have to use it yet, so I'm not familiar with it yet, I saw the tutorial about it in the online training but other than that I have nothing on it.

posipova
20-Turquoise
(To:fgrondin)

fgrondin
5-Regular Member
(To:posipova)

Oh, and by using that technique, wouldn't it give me a binary / xml file ?

It'd better if I could have it in Excel or PDF

posipova
20-Turquoise
(To:fgrondin)

It would give a binary or xml.You could see if PDF extension would work https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS243288&lang=en_US

fgrondin
5-Regular Member
(To:posipova)

I tried making the pdf extension work, but it doesn't for me. I'm just going to use SSRS and write down a link and when the user click on that link it shows all the data in the SSRS report.

Top Tags