In this video, you will learn how to read, write and modify spreadsheets in Centrldesk.
Spreadsheets like Excel files are useful for many use cases and can be found in almost every company worldwide. In this example, we will read an existing Excel file, add a new column with content in Centrldesk and generate a new Excel file for downloading. So let's start building our application:
Steps:
- First, we go to the page editor by clicking on the Edit Page button.
- Add a file upload element using drag and drop.
- Change the placeholder name of the file upload element to "Upload an Excel file".
- Add a button using drag and drop.
- Change the name of the button to "Save modified Excel file", and choose an icon and a color.
- With Centrldesk, you can easily customize your applications and graphical user interfaces to meet your needs.
- Next, we add an action to the button by clicking the "Add" function on the "On Click" event.
- The Flow Editor opens.
- On the left side, under Libraries, we now drag and drop the "File Processing" element into the center of the Flow Editor.
- The "File Processing" dialog opens.
- Select "Read Spreadsheet File" on the left side and confirm with OK.
- On the left side, under General, we now drag and drop the "For Each" element into the center of the Flow Editor.
- On the left side, under Libraries, we now drag and drop the "File Processing" element into the center of the Flow Editor.
- The "File Processing" dialog opens.
- Select "Write Spreadsheet File" on the left side and confirm with OK.
- On the left side, under Libraries, we now drag and drop the "File Processing" element into the center of the Flow Editor.
- The "File Processing" dialog opens.
- Select "Download Files" on the left side and confirm with OK.
- Connect the output of the Read Spreadsheet File block to the input of the For Each block.
- Connect the output of the For Each block to the input of the Write Spreadsheet File block.
- Connect the output of the Write Spreadsheet File block to the input of the Download Files block.
- Select the For Each block.
- Select List as Item Type on the right side.
- Select Mixed for the second Item Type on the right side.
- On the right side at List select "Custom".
- The logic editor opens.
- Drag and drop the spreadsheet workbook block from the left side to the center of the Logic Editor.
- On the right side, under Libraries, we now drag and drop the "System Object" element into the center of the Flow Editor.
- The "System Object" dialog opens.
- Scroll Down and select "Split Spreadsheet Workbook" on the left side and confirm with OK.
- On the right side, under Libraries, we now drag and drop the "List" element into the center of the Flow Editor.
- The "List" dialog opens.
- Select "Get First Item From List" on the left side and confirm with OK.
- On the right side, under Libraries, we now drag and drop the "System Object" element into the center of the Flow Editor.
- The "System Object" dialog opens.
- Scroll Down and select "Split Spreadsheet" on the left side and confirm with OK.
- Now connect all outputs to the corresponding inputs.
- Close the Logic Editor by clicking close in the upper right corner.
- Select the For Each block.
- Click on the "Edit Sub flow" Button below the for each block.
- On the left side, under General, we now drag and drop the "Logic" element into the center of the Flow Editor.
- Select the "Logic" block and click on the "Edit" button.
- Drag and drop the Item block from the left side to the center of the Logic Editor.
- On the right side, under Libraries, we now drag and drop the "List" element into the center of the Flow Editor.
- The "List" dialog opens.
- Select "Insert List Item" on the left side and confirm with OK.
- Connect the output of the Item block to the list input of the Insert List Item block.
- Now we want to add to the existing data from our imported Excel spreadsheet a new column at index one with the value "Active User" for each row.
- On the right side, under Libraries, we now drag and drop the "General" element into the center of the Flow Editor.
- The "General" dialog opens.
- Select "Value" on the left side and confirm with OK.
- Select "Number" as "Type" and one as value and confirm with OK.
- On the right side, under Libraries, we now drag and drop the "General" element into the center of the Flow Editor.
- The "General" dialog opens.
- Select "Value" on the left side and confirm with OK.
- Select "Text" as "Type" and the string "Active User" as value and confirm with OK.
- Connect the output of the number value block to the index input of the Insert List Item block.
- Connect the output of the text value block to the Item one input of the Insert List Item block.
- Close the Logic Editor by clicking close in the upper right corner.
- Navigate back in the Flow Editor by clicking back in the left upper corner.
- Select the Write Spreadsheet File block.
- On the right side at Spreadsheet Workbook select "Spreadsheet Workbook".
- On the right side at Filename select "Enter Value" and enter a filename.
- Select the Download files block.
- On the right side at Source One select "Spreadsheet File".
- Close the Flow Editor by clicking close in the upper right corner.
- Close the Page Editor by clicking Close in the upper left corner.
- Now we can start using our application.
- The Excel file we import looks as follows.
- In our flow, we have defined that we will insert an additional column after column A and fill it with the text value "Active User".
- Clicking on the "File Upload" button opens a file chooser dialog.
- Select the Excel file in the file system and confirm it with open.
- Clicking on the "Save modified Excel file" generates our modified new Excel File.
- The Downloads dialog with the automatically created Excel file is displayed.
- Clicking on the Excel file will open a save-to-file system dialog.
- Confirm with save.
- Now we can see our newly created Excel file with the inserted column and values.