### Complete Spreadsheet Workflow in TypeScript Source: https://context7.com/aaartyukhov/spreadsheet-editor-interface/llms.txt This TypeScript code demonstrates initializing a workbook, creating sheets, populating cells with data, applying formatting (bold, background color, font color, borders, font size), adding a total row, creating a summary sheet with a title, adding a bar chart for visualization, setting the active sheet, and finally saving the workbook in XLSX, PDF, and HTML formats. It requires the IWorkbook, ISheet, IRange, ICell, and IChart interfaces from the spreadsheet editor library. ```typescript const workbook: IWorkbook = new Workbook(); const dataSheet: ISheet = workbook.addSheet('Monthly Sales'); const headers: IRange = dataSheet.getRange(1, 1, 1, 4); headers.setValues([['Product', 'Units Sold', 'Unit Price', 'Total Revenue']]); headers.setBold(true); headers.setBackgroundColor('#2F5496'); headers.setFontColor('#FFFFFF'); headers.setFontSize(11); headers.setBorder('medium', '#000000'); const salesData: IRange = dataSheet.getRange(2, 1, 7, 4); salesData.setValues([ ['Laptop Pro', 150, 1299.99, 194998.50], ['Desktop Elite', 85, 1899.99, 161499.15], ['Tablet Max', 320, 599.99, 191996.80], ['Smartphone X', 450, 899.99, 404995.50], ['Headphones Premium', 680, 199.99, 135993.20], ['Mouse Wireless', 920, 49.99, 45990.80] ]); salesData.setBorder('thin', '#CCCCCC'); const priceRange: IRange = dataSheet.getRange(2, 3, 7, 4); priceRange.setFontColor('#006100'); const totalRow: IRange = dataSheet.getRange(8, 1, 8, 4); totalRow.setValues([['TOTAL', 2605, '', 1135474.95]]); totalRow.setBold(true); totalRow.setBackgroundColor('#D9E1F2'); totalRow.setBorder('thick', '#000000'); const summarySheet: ISheet = workbook.addSheet('Dashboard'); const summaryTitle: ICell = summarySheet.getCell(1, 1); summaryTitle.value = 'Sales Dashboard - October 2025'; summaryTitle.setFontSize(18); summaryTitle.setBold(true); const chartRange: IRange = dataSheet.getRange(1, 1, 7, 2); const chart: IChart = summarySheet.addChart( chartRange, 'bar', { row: 3, column: 1, width: 700, height: 450 } ); chart.setTitle('Units Sold by Product'); chart.setLegend(false); workbook.setActiveSheet('Dashboard'); workbook.save('sales_report_oct_2025.xlsx'); workbook.exportAs('pdf', 'sales_report_oct_2025.pdf'); workbook.exportAs('html', 'sales_report_oct_2025.html'); console.log('Report generated successfully'); ``` -------------------------------- ### Bulk Operations on Cell Ranges using IRange (TypeScript) Source: https://context7.com/aaartyukhov/spreadsheet-editor-interface/llms.txt Demonstrates how to use the IRange interface to perform bulk operations on cell ranges, including setting values, formatting, merging, and clearing cells. It requires an ISheet object and operates on specified cell ranges. ```typescript const sheet: ISheet = workbook.addSheet('Sales Report'); // Define and populate a data range const headerRange: IRange = sheet.getRange(1, 1, 1, 5); headerRange.setValues([ ['Month', 'Revenue', 'Expenses', 'Profit', 'Growth %'] ]); headerRange.setBold(true); headerRange.setBackgroundColor('#4472C4'); headerRange.setFontColor('#FFFFFF'); headerRange.setFontSize(12); headerRange.setBorder('medium', '#000000'); // Populate data rows const dataRange: IRange = sheet.getRange(2, 1, 6, 5); dataRange.setValues([ ['January', 50000, 30000, 20000, 5.2], ['February', 55000, 32000, 23000, 15.0], ['March', 60000, 35000, 25000, 8.7], ['April', 58000, 33000, 25000, 0.0], ['May', 62000, 34000, 28000, 12.0] ]); // Format data area dataRange.setBorder('thin', '#CCCCCC'); dataRange.setFontSize(10); // Highlight total row const totalRange: IRange = sheet.getRange(7, 1, 7, 5); totalRange.setBackgroundColor('#D9E1F2'); totalRange.setBold(true); // Merge cells for title const titleRange: IRange = sheet.getRange(1, 6, 1, 8); titleRange.merge(); const titleCell: ICell = titleRange.getCell(0, 0); titleCell.value = 'Summary Statistics'; // Get values from range const values: any[][] = dataRange.getValues(); console.log(`Retrieved ${values.length} rows of data`); // Clear range const tempRange: IRange = sheet.getRange(10, 1, 15, 3); tempRange.setValues([['temp', 'data', 'here']]); tempRange.clear(); // Unmerge cells titleRange.unmerge(); ``` -------------------------------- ### Create and Customize Charts using IChart (TypeScript) Source: https://context7.com/aaartyukhov/spreadsheet-editor-interface/llms.txt Illustrates how to create various chart types (column, pie, line) from data ranges using the IChart interface. It includes options for setting titles, legends, positions, data ranges, and chart types, as well as removing charts. Requires ISheet and IRange objects. ```typescript const sheet: ISheet = workbook.addSheet('Analytics'); // Prepare chart data const dataRange: IRange = sheet.getRange(1, 1, 6, 3); dataRange.setValues([ ['Quarter', 'Sales', 'Target'], ['Q1', 45000, 50000], ['Q2', 52000, 55000], ['Q3', 58000, 60000], ['Q4', 61000, 65000] ]); // Create column chart const columnChart: IChart = sheet.addChart( dataRange, 'column', { row: 8, column: 1, width: 600, height: 400 } ); columnChart.setTitle('Quarterly Sales Performance'); columnChart.setLegend(true); // Create pie chart for market share const pieDataRange: IRange = sheet.getRange(1, 5, 5, 2); pieDataRange.setValues([ ['Product', 'Share'], ['Product A', 35], ['Product B', 28], ['Product C', 22], ['Product D', 15] ]); const pieChart: IChart = sheet.addChart( pieDataRange, 'pie', { row: 8, column: 5, width: 500, height: 400 } ); pieChart.setTitle('Market Share Distribution'); // Create line chart for trends const trendRange: IRange = sheet.getRange(1, 8, 13, 2); const lineChart: IChart = sheet.addChart( trendRange, 'line', { row: 15, column: 1, width: 800, height: 350 } ); lineChart.setTitle('12-Month Revenue Trend'); lineChart.setLegend(false); // Reposition chart lineChart.setPosition({ row: 20, column: 1, width: 900, height: 400 }); // Change chart type lineChart.setChartType('area'); // Update data range const newRange: IRange = sheet.getRange(1, 1, 10, 3); lineChart.setDataRange(newRange); // Remove chart const removed: boolean = columnChart.remove(); console.log(`Chart removed: ${removed}`); // Get all charts const allCharts: IChart[] = sheet.getCharts(); console.log(`Total charts on sheet: ${allCharts.length}`); ``` -------------------------------- ### Create and Manage Workbook - TypeScript Source: https://context7.com/aaartyukhov/spreadsheet-editor-interface/llms.txt Manages spreadsheet documents, supporting sheet operations, file handling, and exporting to various formats like XLSX, CSV, and PDF. It allows creating new workbooks, adding/removing/renaming sheets, and saving/exporting the entire workbook. ```typescript const workbook: IWorkbook = new Workbook(); const salesSheet: ISheet = workbook.addSheet('Sales', 0); const summarySheet: ISheet = workbook.addSheet('Summary', 1); const allSheets: ISheet[] = workbook.getSheets(); console.log(`Total sheets: ${allSheets.length}`); workbook.setActiveSheet('Sales'); const activeSheet: ISheet | null = workbook.getActiveSheet(); workbook.renameSheet('Sales', 'Q1 Sales'); workbook.save('financial_report.xlsx'); workbook.exportAs('pdf', 'financial_report.pdf'); workbook.exportAs('csv', 'sales_data.csv'); const removed: boolean = workbook.removeSheet('Summary'); ``` -------------------------------- ### Work with Spreadsheet Sheets - TypeScript Source: https://context7.com/aaartyukhov/spreadsheet-editor-interface/llms.txt Provides methods to interact with individual worksheet elements, including cells and ranges. It supports manipulating rows and columns, adding charts, and retrieving information about the used range within the sheet. ```typescript const sheet: ISheet = workbook.addSheet('Product Data'); const headerCell: ICell = sheet.getCell(1, 1); headerCell.value = 'Product Name'; headerCell.setBold(true); sheet.insertRow(5, 2); sheet.deleteRow(10, 1); sheet.insertColumn(3, 1); sheet.deleteColumn(8, 2); const usedRange: IRange | null = sheet.getUsedRange(); if (usedRange) { console.log(`Data spans from row ${usedRange.startRow} to ${usedRange.endRow}`); } const dataRange: IRange = sheet.getRange(2, 1, 10, 4); const chartRange: IRange = sheet.getRange(1, 1, 10, 3); const chart: IChart = sheet.addChart( chartRange, 'bar', { row: 12, column: 1, width: 800, height: 400 } ); const charts: IChart[] = sheet.getCharts(); ``` -------------------------------- ### Manipulate Cell Data and Formatting - TypeScript Source: https://context7.com/aaartyukhov/spreadsheet-editor-interface/llms.txt Enables direct access and modification of cell values and their formatting properties, including fonts, colors, and text styles. It also allows clearing cell content and retrieving cell-specific information. ```typescript const sheet: ISheet = workbook.addSheet('Invoice'); const titleCell: ICell = sheet.getCell(1, 1); titleCell.value = 'INVOICE #12345'; titleCell.setBold(true); titleCell.setFontSize(16); titleCell.setFontColor('#0066CC'); titleCell.setBackgroundColor('#F0F0F0'); const dateCell: ICell = sheet.getCell(2, 1); dateCell.value = new Date('2025-10-23'); dateCell.setItalic(true); const formattedValue: string = dateCell.getFormattedValue(); console.log(`Formatted date: ${formattedValue}`); const amountCell: ICell = sheet.getCell(5, 3); amountCell.value = 1250.50; amountCell.setFontSize(12); amountCell.setBackgroundColor('#FFFFCC'); const emptyCell: ICell = sheet.getCell(10, 5); emptyCell.value = 'Temporary'; emptyCell.clear(); console.log(`Cell at row ${titleCell.row}, column ${titleCell.column}`); console.log(`Belongs to sheet: ${titleCell.sheet.name}`); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.