Skip to main content

import-data

PRO

The functionality is available in PRO Edition only

Description​

Triggers import of MS Project XML data to Gantt

You need to handle file upload, read file contents as text and send the resulting string to the action

Usage​

"import-data": ({
data: string,
}) => void;

Parameters​

  • string - (required) XML string from the uploaded XML file

Example​

<script>
import { Gantt } from "@svar/svelte-gantt";

let api = $state();

function importMSProject() {
// your uploader control
const file = document.getElementById("import-file").files[0];
const reader = new FileReader();
reader.onload = e => {
const xml = e.target.result;
api.exec("import-data", {
data: xml,
});
};
reader.readAsText(file);
}
</script>

<Gantt bind:this={api}/>

Related articles: