Export and Import Org Chart to Excel

Export and Import Org Chart to Excel

Export and Import Org Chart to Excel: How to Export an Org Chart to Excel with OrgChart JS

How to Export an Org Chart to Excel with OrgChart JS

Creating dynamic, interactive organization charts is easier than ever thanks to libraries like OrgChart JS. But what if you want to export your org chart data to an Excel file or load it from one? Here's a simple way to do it using OrgChart JS and SheetJS.

Code example

🛠️ What You’ll Need

Include these scripts in your HTML:

<script src="https://cdn.balkan.app/orgchart.js"></script>
<script src="https://unpkg.com/xlsx/dist/xlsx.full.min.js"></script>

And set up your page:

<div id="tree"></div>
<div id="controls">
    <input type="file" id="excelFile" accept=".xlsx, .xls">
    <button onclick="saveDataToExcel()">Save to Excel</button>
</div>

📊 Initializing the Org Chart

We start by initializing the chart with some sample data:

let chart = new OrgChart(document.getElementById("tree"), {
    nodeBinding: {
        field_0: "name",
        field_1: "title"
    }
});

chart.load([
    { id: 1, name: "Amber McKenzie" },
    { id: 2, pid: 1, name: "Ava Field" },
    { id: 3, pid: 1, name: "Peter Stevens" }
]);

📥 Importing Org Chart Data from Excel

Users can upload an Excel file, which is then read and converted into chart data:

document.getElementById('excelFile').addEventListener('change', function (event) {
    const file = event.target.files[0];
    readExcelData(file);
});

function readExcelData(file) {
    const reader = new FileReader();

    reader.onload = function (e) {
        const data = new Uint8Array(e.target.result);
        const workbook = XLSX.read(data, { type: 'array' });
        const sheetName = workbook.SheetNames[0];
        const worksheet = workbook.Sheets[sheetName];
        const jsonData = XLSX.utils.sheet_to_json(worksheet);

        chart.load(jsonData);
    };

    reader.readAsArrayBuffer(file);
}

📤 Exporting Org Chart to Excel

To export the chart data to an Excel file, simply call:

function saveDataToExcel() {
    const data = chart.config.nodes;
    const worksheet = XLSX.utils.json_to_sheet(data);
    const workbook = XLSX.utils.book_new();
    XLSX.utils.book_append_sheet(workbook, worksheet, 'OrgChartData');
    XLSX.writeFile(workbook, 'orgchart.xlsx');
}

âś… Final Thoughts

This setup allows you to easily save and load your org chart data in Excel format—perfect for backups, editing outside the browser, or sharing with colleagues. With just a few lines of code, your org chart becomes even more powerful and user-friendly.


Export to Excel - OrgChart JS

React OrgChart

Create and run an OrgChart Single Page Application with Node.js – beginner's guide.

Adding Custom HTML Elements into OrgChart JS container

Еasily Create a Template in an OrgChart

Node Swapping in an Organizational Chart

Vladimir Putin Family Tree

Add Field Data in Expand button with OrgChart JS

Bill Gates Family Tree

Create a Tooltip for a ForeignObject Element Hover in OrgChart JS

Custom Aligning Nodes in a JavaScript Organizational Chart

Center and Zoom on Search Click in OrgChart JS

Create Multiline Group Titles in OrgChart JS

Adding Arrows in OrgChart JS Links

Show a Custom Edit Form for a node in OrgChart JS

Jeff Bezos Family Tree

How to Add Material Icons in OrgChart JS

Leonardo DiCaprio Family Tree

Visualizing Dual Reporting Structures with OrgChart JS

Exporting OrgChart JS to A4 PDF: A Step-by-Step Guide

Genghis Khan Family Tree: The Lineage of the Great Khan

OrgChart JS now support Export to Visio

New Export Option: childLevels in OrgChart JS

Elon Musk Family Tree

AI for OrgChart JS: Revolutionizing Organization Charts

Family Tree JS 2 (Preview)

d3 org chart

Our Family Tree App is Now on Android!

Why BALKAN OrgChart JS is the Best Organizational Chart Library

How to Create a JavaScript Flow Chart

How to Add an Organizational Chart to a Mobile Application

How to Create a JavaScript Organizational Chart

OrgChart JS Now Supports PDF Export Per Team

Introducing Family Tree App

Donald Trump Family Tree

Discover Your Roots: Build Your Family Tree with BALKAN App

JavaScript Organization Chart

Instantly create interactive, intuitive flowcharts in seconds

JavaScript Hierarchy Chart

Mermaid js alternative

Create Flowcharts in Seconds with Flow Chart JS: Your New Favorite JavaScript Library

Customizing Filter UI - Code of The Week

Zoom Slider - Code of The Week

Bookmarks - Code of The Week

Customizing Search Results - Code of The Week

Introducing Undo Redo - Code Of The Week

Price adjustment announcement

The price will increase for new customers

Buttons for adding family members to a family tree - Code of The Week

Levels - Code of The Week

Change node color from a button in the Edit Form - Code of The Week

Filter and Highlight Nodes - Code of The Week

Up Expanding - Code Of The Week

Programmatically move the chart - Code of The Week

Siblings in Family Tree JS - Code of The Week

Purple template - Code of The Week

Assistant With Children - Code of The Week

Conditional Layout - Code of The Week

Conditional Color - Code of the Week

Sriniz Family Tree Template - Code of The Week

Color Picker - Code of The Week

Add company logo as watermark in exported PDF documents - Code of The Week

Mind map - Code of The Week

Create relationship with circle menu - Code of The Week

Animated Photos - Code of the Week

Grouped Dotted Lines - Code Of The Week

Dotted Lines - Code Of The Week

Department Dynamic Title - Code Of The Week

Add expand button for partners - Code of the Week

Change the sub levels with Drag and Drop - Code of The Week

Custom Edit From using Popover - Code of the Week

Sub levels tag option - Code of the Week

Highlights search results directly on Org Chart nodes - Code of the Week

Code of the Week/Relationship maps and Business process diagrams

Search using field name abbreviations - Code of the Week

Dynamic Template - Code of the Week

Read and Write local CSV file using File API and Org Chart JS - Code of The Week

Organizational Chart Path Highlighting and Selection

Modern Template - Org Chart JS

Performance - Org Chart JS

Single parent is supported in Family Tree JS

How To Develop a Flowchart Maker with Org Chart JS

How to upload a photo to Family Tree JS in .NET core

How to change the color of selected node - Family Tree JS

Family Tree with live tiles

Error

BALKAN Blog

The Latest BALKAN App News and Releases. Latest information on Org Chart JS and Family Tree JS.