About tables

更新时间:
复制 MD 格式

Perform operations on spreadsheets, such as exporting to PDF, retrieving sheet names, and switching sheets.

Important

This document is no longer maintained. Use the new version of Intelligent Media Management.

Export to PDF

  // Export the workbook as a PDF document.
  await demo.ExcelApplication().ActiveWorkbook.ExportAsFixedFormat()
  // Export the current sheet of the workbook as a PDF document.
  await demo.ExcelApplication().ActiveWorkbook.ActiveSheet.ExportAsFixedFormat()

Get sheet names and switch sheets

  • Retrieve all sheet names

    await demo.ready()
    const app = demo.ExcelApplication()
    const Names = []
    // For(start, end, step, handle)
    await app.For(1, app.Sheets.Count, 1, async (Index) => {
        Names.push(await app.Sheets.Item(Index).Name)
    })
    console.log(Names)
  • Retrieve the current sheet name

    await demo.ready()
    const app = demo.ExcelApplication()
    const name = await app.ActiveSheet.Name
    console.log('ActiveSheet:', name)
  • Switch to a specific sheet

    await demo.ready()
    const app = demo.ExcelApplication()
    const sheetIndex = 1 // The sheet index, starting from 1.
    app.Sheets.Item(sheetIndex).Activate() // Switch the sheet.
  • Sheet switch callback event

    await demo.ready()
    const app = demo.Application
    app.Sub.Worksheet_Activate = async function() {
        console.log("ActiveSheet:", await app.ActiveSheet.Name)
    }