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​

import { useRef } from "react";
import { Gantt } from "@svar/react-gantt";

function App() {
const api = useRef(null);

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.current.exec("import-data", {
data: xml,
});
};
reader.readAsText(file);
}

return <Gantt ref={api} />;
}

Related articles: