Open your data directly in Excel for the Web with zero installation - A JavaScript library that converts web tables and data into interactive Excel workbooks with Power Query integration and custom branded templates
Transform your web applications with enterprise-grade Excel integration that goes far beyond simple CSV exports.
Convert raw data or HTML tables arrays to Excel tables while preserving data types, ensuring your data maintains its structure and formatting. instead of basic CSV exports that lose all structure and functionality.
Launch workbooks directly in Excel for the Web through any browser without requiring Excel desktop installation, making your data accessible to any user anywhere. No installation required, works on any device.
Inject your data into pre-built Excel templates containing your company branding, PivotTables, charts, and business logic while preserving all formatting and calculations. Use your own branded Excel templates with PivotTables and charts to maintain corporate identity and pre-built analytics.
Create workbooks that automatically refresh from your web APIs, databases, or data sources using Microsoft's Power Query technology, eliminating manual data updates. Create workbooks that refresh data on-demand using Power Query for real-time data updates and automated reporting.
Full control over document properties including title and description for professional document management, allowing you to customize metadata and maintain enterprise standards.
Open In Excel powers data export functionality across Microsoft's enterprise platforms:
npm install @microsoft/connected-workbooks
Perfect for quick data exports from existing web tables.
import { workbookManager } from '@microsoft/connected-workbooks';
// One line of code to convert any table
const blob = await workbookManager.generateTableWorkbookFromHtml(
document.querySelector('table') as HTMLTableElement
);
// Open in Excel for the Web with editing enabled
workbookManager.openInExcelWeb(blob, "QuickExport.xlsx", true);
Transform raw data arrays into professionally formatted Excel tables.
import { workbookManager } from '@microsoft/connected-workbooks';
const salesData = {
config: {
promoteHeaders: true, // First row becomes headers
adjustColumnNames: true // Clean up column names
},
data: [
["Product", "Revenue", "InStock", "Category", "LastUpdated"],
["Surface Laptop", 1299.99, true, "Hardware", "2024-10-26"],
["Office 365", 99.99, true, "Software", "2024-10-26"],
["Azure Credits", 500.00, false, "Cloud", "2024-10-25"],
["Teams Premium", 149.99, true, "Software", "2024-10-24"]
]
};
const blob = await workbookManager.generateTableWorkbookFromGrid(salesData);
workbookManager.openInExcelWeb(blob, "SalesReport.xlsx", true);
Transform your data using pre-built Excel templates with your corporate branding.
Steps:
-
Prepare Your Template File
Open Excel and create (or open) your branded file.
-
Pick one sheet that will hold your data.
The default "Sheet1"(3)
-
Inside that sheet, choose were you want your data to be populated(1) and create a table (Insert β Table).
The default table name is Table1(2)
The table need to have the same column structure as your incoming data. -
Add any charts, formulas, or formatting that reference this table.
Example: Pie chart using Gross column(4).
-
Save the Excel file (e.g., my-template.xlsx).
-
Use the saved file as the template for your incoming data
The library will then populate the designated table with your data. Any functions, figures, or references linked to this table within the Excel template will automatically reflect the newly exported data.
// Method 1: File upload from user
const templateInput = document.querySelector('#template-upload') as HTMLInputElement;
const templateFile = templateInput.files[0];
// Method 2: Fetch from your server
const templateResponse = await fetch('/assets/templates/sales-dashboard.xlsx');
const templateFile = await templateResponse.blob();
// Method 3: Drag and drop
function handleTemplateDrop(event: DragEvent) {
const templateFile = event.dataTransfer.files[0];
// Use templateFile with the library
}
const quarterlyData = {
config: { promoteHeaders: true, adjustColumnNames: true },
data: [
["Region", "Q3_Revenue", "Q4_Revenue", "Growth", "Target_Met"],
["North America", 2500000, 2750000, "10%", true],
["Europe", 1800000, 2100000, "17%", true],
["Asia Pacific", 1200000, 1400000, "17%", true],
["Latin America", 800000, 950000, "19%", true]
]
};
// Inject data into your branded template
const blob = await workbookManager.generateTableWorkbookFromGrid(
quarterlyData,
undefined, // Use template's existing data structure
{
templateFile: templateFile,
TempleteSettings: {
sheetName: "Dashboard", // Target worksheet
tableName: "QuarterlyData" // Target table name
}
}
);
// Users get a fully branded report
workbookManager.openInExcelWeb(blob, "Q4_Executive_Dashboard.xlsx", true);
π‘ Template Requirements: Include a query named "Query1" connected to a Table.
Create workbooks that automatically refresh from your data sources.
import { workbookManager } from '@microsoft/connected-workbooks';
// Create a workbook that connects to your API
const blob = await workbookManager.generateSingleQueryWorkbook({
queryMashup: `let
Source = {1..10}
in
Source`,
refreshOnOpen: true
});
workbookManager.openInExcelWeb(blob, "MyData.xlsx", true);
### π **Professional Document Properties**π Learn Power Query: New to Power Query? Check out the official documentation to unlock the full potential of live data connections.
Add metadata and professional document properties for enterprise use.
const blob = await workbookManager.generateTableWorkbookFromHtml(
document.querySelector('table') as HTMLTableElement,
{
docProps: {
createdBy: 'John Doe',
lastModifiedBy: 'Jane Doe',
description: 'Sales Report Q4 2024',
title: 'Quarterly Sales Data'
}
}
);
// Download for offline use
workbookManager.downloadWorkbook(blob, "MyTable.xlsx");
Create Power Query connected workbooks with live data refresh capabilities.
async function generateSingleQueryWorkbook(
query: QueryInfo,
grid?: Grid,
fileConfigs?: FileConfigs
): Promise<Blob>
Parameter | Type | Required | Description |
---|---|---|---|
query |
QueryInfo |
β Required | Power Query configuration |
grid |
Grid |
Optional | Pre-populate with data |
fileConfigs |
FileConfigs |
Optional | Customization options |
Convert HTML tables to Excel workbooks instantly.
async function generateTableWorkbookFromHtml(
htmlTable: HTMLTableElement,
fileConfigs?: FileConfigs
): Promise<Blob>
Parameter | Type | Required | Description |
---|---|---|---|
htmlTable |
HTMLTableElement |
β Required | Source HTML table |
fileConfigs |
FileConfigs |
Optional | Customization options |
Transform raw data arrays into formatted Excel tables.
async function generateTableWorkbookFromGrid(
grid: Grid,
fileConfigs?: FileConfigs
): Promise<Blob>
Parameter | Type | Required | Description |
---|---|---|---|
grid |
Grid |
β Required | Data and configuration |
fileConfigs |
FileConfigs |
Optional | Customization options |
Open workbooks directly in Excel for the Web.
async function openInExcelWeb(
blob: Blob,
filename?: string,
allowTyping?: boolean
): Promise<void>
Parameter | Type | Required | Description |
---|---|---|---|
blob |
Blob |
β Required | Generated workbook |
filename |
string |
Optional | Custom filename |
allowTyping |
boolean |
Optional | Enable editing (default: false) |
Trigger browser download of the workbook.
function downloadWorkbook(file: Blob, filename: string): void
Get the Excel for Web URL without opening (useful for custom integrations).
async function getExcelForWebWorkbookUrl(
file: Blob,
filename?: string,
allowTyping?: boolean
): Promise<string>
Power Query configuration for connected workbooks.
interface QueryInfo {
queryMashup: string; // Power Query M language code
refreshOnOpen: boolean; // Auto-refresh when opened
queryName?: string; // Query identifier (default: "Query1")
}
Data structure for tabular information.
interface Grid {
data: (string | number | boolean)[][]; // Raw data rows
config?: GridConfig; // Processing options
}
interface GridConfig {
promoteHeaders?: boolean; // Use first row as headers
adjustColumnNames?: boolean; // Fix duplicate/invalid names
}
Advanced customization options.
interface FileConfigs {
templateFile?: File; // Custom Excel template
docProps?: DocProps; // Document metadata
hostName?: string; // Creator application name
TempleteSettings?: TempleteSettings; // Template-specific settings
}
interface TempleteSettings {
tableName?: string; // Target table name in template
sheetName?: string; // Target worksheet name
}
Document metadata and properties.
interface DocProps {
title?: string; // Document title
subject?: string; // Document subject
keywords?: string; // Search keywords
createdBy?: string; // Author name
description?: string; // Document description
lastModifiedBy?: string; // Last editor
category?: string; // Document category
revision?: string; // Version number
}
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
git clone https://github.com/microsoft/connected-workbooks.git
cd connected-workbooks
npm install
npm run build
npm test
This project is licensed under the MIT License - see the LICENSE file for details.
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.
Power Query, Excel, Office, Workbook, Refresh, Table, xlsx, export, CSV, data export, HTML table, web to Excel, JavaScript Excel, TypeScript Excel, Excel template, PivotTable, connected data, live data, data refresh, Excel for Web, browser Excel, spreadsheet, data visualization, Microsoft Office, Office 365, Excel API, workbook generation, table export, grid export, Excel automation, data processing, business intelligence