VSeed, an elegant data composer, transforming complexity into simplicity.
!!!###!!!title=multi sheet——VisActor/VTable tutorial documents!!!###!!!!!!###!!!description=VTable-Sheet supports managing multiple sheets within a single instance, similar to Excel's workbook functionality. This chapter explains how to create, switch between, and manage multiple sheets.!!!###!!!
Multi-Sheet Management
VTable-Sheet supports managing multiple sheets within a single instance, similar to Excel's workbook functionality. This chapter explains how to create, switch between, and manage multiple sheets.
Creating Multiple Sheets
When initializing VTableSheet, you can define multiple sheets using the sheets configuration option:
const sheetInstance = new VTableSheet(document.getElementById('container'), {
showSheetTab: true, // Show sheet tabs at the bottom, recommended for multi-sheet usagesheets: [
{
sheetKey: 'sheet1',
sheetTitle: 'Sales Data',
data: [
['Product', 'January', 'February', 'March'],
['Product A', 1200, 1500, 900],
['Product B', 950, 1100, 1300]
],
active: true// Set as the active sheet },
{
sheetKey: 'sheet2',
sheetTitle: 'Inventory Data',
data: [
['Product', 'Quantity', 'Safety Stock'],
['Product A', 500, 200],
['Product B', 300, 150]
]
}
]
});
Switching Between Sheets
When multiple sheets are configured and the showSheetTab option is enabled, users can switch between different sheets by clicking on the sheet tabs at the bottom.
You can also programmatically switch between sheets:
// Activate a sheet by its keysheetInstance.activateSheet('sheet2');
// Remove a sheet by its keysheetInstance.removeSheet('sheet3');
Getting Sheet Information
VTableSheet provides various methods to get information about sheets:
// Get the currently active sheetconst activeSheet = sheetInstance.getActiveSheet();
// Get a specific sheet by its keyconst sheet2 = sheetInstance.getSheetByKey('sheet2');
// Get all sheetsconst allSheets = sheetInstance.getAllSheets();
// Get the total number of sheetsconst sheetCount = sheetInstance.getSheetCount();
Sheet Configuration Options
Each sheet can be independently configured with the following properties:
Option
Type
Description
sheetKey
string
Unique identifier for the sheet
sheetTitle
string
Name displayed on the tab
data
any[][]
Sheet data
columns
object[]
Column definitions
active
boolean
Whether this sheet is active
filter
boolean | object
Whether to enable filtering
frozenRowCount
number
Number of frozen rows
frozenColCount
number
Number of frozen columns
showHeader
boolean
Whether to display the header
rowCount
number
Number of rows
columnCount
number
Number of columns
cellMerge
object[]
Cell merge settings
Sheet Operation Events
TODO
VTableSheet provides a series of events related to sheet operations: