Store File and Load File
StoreFile.SK function is used to store files uploaded by a user on a database whereas LoadFile.SK is used to retrieve the uploaded file from the database.
StoreFile.SK function is used to store files uploaded by a user on a database .
StoreFile.SK can be accessed by typing the formula out in a cell. (See Figure)
To use this particular function, a database has to be created using the database explorer option. This particular database is where all the files necessary will be stored using the StoreFile.SK function.
Database Explorer can be accessed by clicking on the database explorer option available in the SheetKraft toolbar.
Click on the Database explorer button and a dialogue box will appear.
Now click on Create file Entries Table.
Once the dialogue box appears, please specify the schema name and table name of your choice. These options are present at the bottom of the dialogue box (See figure).
After doing so, click on the generate SQL table.
On doing this, you should get a successfully generated message.
(see figure below)
Now click on the SQL tab and then click on Run-Non query at the bottom of the dialogue box. On doing so, query successfully executed message shows up as indicated in the figure below.
Since the function StoreFile.SK function has not been implemented in Sheetkraft Add-in, we will have to publish the activity on the server to understand how it is working.
Let us create a sample activity to see how this function is used.
We will be needing a file path to test out this function.
Use the RelativePath.SK formula to generate the file path. Type out the RelativePath.SK formula into a cell and press enter.
You will get the path of the current file you are using.
Now let us take a look at the different arguments to be passed through StoreFile.SK function. Type out the function in a cell and click on the Fx button. (See figure)
A dialogue box appears on clicking the Fx button which shows us the arguments to be entered in the StoreFile.SK function.
The arguments are:
File Path – The respective path of the file which has to be stored. NOTE: Do not specify a static path as an input for this argument.
Schema Name – The schema name with which the table for the purpose of storing files was created.
Table Name – The table name with which the table for the purpose of storing files was created.
Refer to Step3 for clarification on Schema name and Table name.
Once you click on ok after entering the argument will be seen as above. (See above figure)
The actual output of the StoreFile.SK function is a FileId which is generated. The Id generated is unique for each file stored. This Id cannot be seen now on SheetKraft as this particular function has not been implemented in the SheetKraft Add-in.
When you click on the Run Book button, you will see a warning as shown below in the figure.
To generate the final output of File Id, this particular activity has to be published on the server and run.
Publish this activity without defining any input or output as of now to test it out.
Once you run the activity on the server, import the database and check if File Id has been generated. Use Import from database UI to do the same. This can be accessed by clicking on the Import from button on the SheetKraft toolbar. Select the table name correctly while using the DatafromDatabase UI.
On running the formula, the output generated can be seen as above.
The Id column is of most interest to us, as it is unique for each file stored.
LoadFile.SK function is used to retrieve files stored by an user on a database .
LoadFile.SK can be accessed by typing the formula out in a cell. (See Figure)
Enter the formula and click on the Fx button to see the arguments required for the Loadfile.SK function.
Argument to be filled:
File Id - The file Id generated using StoreFile.SK is the only input to be given.
Once you click on Ok after entering the input field, the output will be a #Value! Error along with a warning message which says Loadfile has not been implemented in the SheetKraft Add-in. (See above Figure for reference)
For this function to work, you will have to publish the activity while defining the cell containing the LoadFile.SK as an output with the type as File path. (See figure below for reference)
Note: Define activity can be accessed from the SheetKraft toolbar.
Once you run the activity on the server you have published it on. You will get a downloadable file as an output. (See figure below)
NOTE: This is just one instance of how these functions can be used for a single file. Do try it out for multiple files also.