Use cases
To give you an idea for potential use cases, let me throw some at you to think about and we I'll go into detail for one of those use cases.
- Simple integrations with other tools You want to integrate data from another application, but building a full API connection is not feasible. Since most tools offer Excel exports, this method allows you to create a reliable integration with significantly less effort and cost.
- Online form submissions to wiki pages You collect data through an online form that exports to Excel. With this setup, each submission can automatically generate or update a structured wiki page.
- Recurring financial or CRM exports Weekly or monthly exports from your bookkeeping system or CRM can be imported directly. This keeps your wiki updated without needing to manually enter the same type of data each time.
- Bulk data entry or migration When onboarding existing data into the wiki, such as a list of team members or archived reports, an Excel file can be used to quickly create multiple pages.
- Simplifying data entry for non-technical users Colleagues who are not familiar with wikitext can fill out a spreadsheet. That data can then be imported to generate properly structured pages using wiki templates.
How will it work?
Before diving into the details, let’s take a step back. This solution combines FlexForm and the ArrayFunctions extension to make everything happen. FlexForm handles the spreadsheet upload and converts the content into a JSON format. Then, ArrayFunctions reads that JSON data and feeds it into a dynamic FlexForm form. This form can then create or update wiki pages automatically, based on the data in each row.
Error creating thumbnail: File missing
Step-by-Step Guide
1. Install the Required Extensions
ArrayFunctions installation instructions
FlexForm installation instructions
2. Try the Import Yourself
Do you want to try or experiment with this import? If you have the PageSync extension installed, you can install the sharefile on this special page: /Special:WSps?action=share. Note that we use the slot with name 'ws-data', so you might need to change that.
3. Use the Sample Excel Sheet
This example will create person pages based on a spreadsheet with person data. You can download the sample sheet here. The example is simple, but you can adapt the structure to suit your needs.
4. Create the Upload Form
We need to start with being able to upload an Excel sheet and parse it to JSON data. We will create a FlexForm form for this. Here is a simple one derived from the FlexForm docs example that does the job:<form enctype="multipart/form-data" >
<_create noseo mwfollow mwwrite="[FFUploadedFile-NewName-myfile]" mwtemplate="Test excel convert" mwfields="FFUploadedFile-UploadName-myfile::Original filename" />
<input type="file" id="testingFile" name="myfile" parsecontent target="[filename]" action="convertfrom:xlsx" slot="ws-data" accept=".xlsx" target="excel-data-[mwrandom]-[filename]" />
<input type="submit" value="upload" />
</div>
</form>
Explanation:
The <input type="file"> accepts .xlsx files and parses them into JSON.
The action="convertfrom:xlsx" handles the transformation from Excel to JSON.
The saves the template and redirects to the resulting page.
The slot="ws-data" stores the JSON output in a content slot. Using slots is not required, you can also save the slotdata to the main content.
5. Create the Dynamic Form Template
Now, we edit the template that is shown on the page of the Excel sheet ("Test excel convert"). We will create a 'dynamic form'.
We will loop over all persons in the data and create inputs in a form.<includeonly>
<form>
{{#af_foreach: {{#af_get: {{#invoke:CspFunctions|afExportSlots}} | 1 | ws-data }} | key | person |
<!-- Create the person -->
<_create mwwrite="Person/" mwtemplate="Person" mwoption="next_available" mwfields="Name{{{key}}}::Name,Country{{{key}}}::Country" />
<input type="hidden" name="Name{{{key}}}" value="{{#af_get:{{{person}}}|First Name}} {{#af_get:{{{person}}}|Last Name}}" />
<input type="hidden" name="Country{{{key}}}" value="{{#af_get:{{{person}}}|Country}}" />
<!-- List the person -->
{{#af_get:{{{person}}}|First Name}}<br>
}}
<input type="submit" value="Save persons" class="btn btn-primary" />
</form>
</includeonly>
Explanation:
- af_foreach loops over each row (person) in the Excel data.
The generates a Person/ page for each entry using the Person template.
- af_get pulls individual fields like First Name, Last Name, and Country.
hidden inputs ensure the values are correctly passed when the form is submitted.
6. Done!
After uploading the Excel sheet, you are redirected to the page that contains the data (because of the mwfollow attribute). The page confirms which persons will be created, and when you click save, all the person pages are created using the Person template with the appropriate parameters.
This approach saves hours of manual work and gives you full control over how imported data is handled inside your wiki.
|