History
Introduction
API Category
Making API Requests
Region APIs
Instance APIs
Cloud Hosting Cluster APIs
Image APIs
Instance Launch Template APIs
Placement Group APIs
Key APIs
Security Group APIs
Network APIs
Data Types
Error Codes
await demo.ready() // You can call an advanced API only after the demo is ready. The demo object is the object after the JS-SDK is instantiated.
// Textconst wordApp = demo.WordApplication()// Spreadsheetconst excelApp = demo.ExcelApplication()// Presentationconst pptApp = demo.PPTApplication()const pdfApp = demo.PDFApplication()// Automatic recognitionconst app = demo.Application
/** @param: WdInformation: {* wdNumberOfPagesInDocument: 4* }* @return: {PagesCount: number, End: boolean}*/const app = demo.WordApplication()const {Enum} = applet totalPages = await app.ActiveDocument.Range.Information(Enum.WdInformation.wdNumberOfPagesInDocument)if (totalPages.End) {// Getting the total number of pages is an async operation. The obtained number of pages is accurate only after `totalPages.End` becomes `true`.console.log("All pages are loaded. There are ", totalPages.PagesCount, " pages in total.")}
/** @param: WdInformation: {* wdActiveEndPageNumber: 3* }* @return: number*/const app = demo.WordApplication()const {Enum} = applet currentPage = await app.ActiveDocument.Selection.Information(Enum.WdInformation.wdActiveEndPageNumber)
/** @param: { What?: WdGoToItem, Which?: WdGoToDirection.wdGoToAbsolute, Count?: number, Name?: string}* WdGoToItem: {* wdGoToPage: 1,* }* WdGoToDirection: {* wdGoToAbsolute: 1* }* @return: number Return the target page number*/const app = demo.WordApplication()const {Enum} = appconst page = await app.ActiveDocument.Selection.GoTo(Enum.WdGoToItem.wdGoToPage, Enum.WdGoToDirection.wdGoToAbsolute, 10)// Orconst page = await app.ActiveDocument.Selection.GoTo({What: Enum.WdGoToItem.wdGoToPage,Which: Enum.WdGoToDirection.wdGoToAbsolute,Count: 10})
/** @param: bool* Valid values: `true` (yes); `false` (no).*/// Hide comments.demo.WordApplication().ActiveDocument.ActiveWindow.View.ShowComments = false
/** @param: bool* Valid values: `true` (yes); `false` (no).*/// Hide the table of contents.demo.WordApplication().ActiveDocument.ActiveWindow.DocumentMap = false
/** @return: number*/await demo.WordApplication().ActiveDocument.ActiveWindow.View.Zoom.Percentage // Read the view zoom level./** @param : 50 <= number <= 300 (The zoom level is between 50% and 300%.)*/demo.WordApplication().ActiveDocument.ActiveWindow.View.Zoom.Percentage = 100 // Set the view zoom level.
const app = demo.ExcelApplication()const Names = []const count = await app.Sheets.Count;for(let index = 1; index <= count; index++) {Names.push(await app.Sheets.Item(index).Name);}console.log(Names)
const app = demo.ExcelApplication()const name = await app.ActiveSheet.Name
const app = demo.ExcelApplication()const sheetIndex = 1 // Sheet number, which starts from 1.app.Sheets.Item(sheetIndex).Activate() // Switch the sheet.
/** @return: number*/await demo.ExcelApplication().ActiveWorkbook.ActiveSheetView.Zoom // Read the view zoom level./** @param : 10 <= number <= 500 (The zoom level is between 10% and 500%.)*/demo.ExcelApplication().ActiveWorkbook.ActiveSheetView.Zoom = 100 // Set the view zoom level.
/** @return: number*/let totalPages = await demo.PPTApplication().ActivePresentation.Slides.Count
/** @return: number*/let totalPages = await demo.PPTApplication().ActivePresentation.SlideShowWindow.View.Slide.SlideIndex
/** @param: number*/await demo.PPTApplication().ActivePresentation.SlideShowWindow.View.GotoSlide(3) // Go to page 3.
await demo.PPTApplication().ActivePresentation.SlideShowSettings.Run()
await demo.PPTApplication().ActivePresentation.SlideShowWindow.View.Exit()
await demo.PPTApplication().ActivePresentation.SlideShowWindow.View.GotoNextClick()
await demo.PPTApplication().ActivePresentation.SlideShowWindow.View.GotoPreClick()
/** @return: string ('preview' | 'play')*/let currentState = await demo.PPTApplication().ActivePresentation.SlideShowWindow.View.State
/** @return: number*/await demo.PPTApplication().ActivePresentation.View.Zoom // Read the view zoom level./** @param : 1 <= number <= 400 (The zoom level is between 1% and 400%.)*/demo.PPTApplication().ActivePresentation.View.Zoom = 100 // Set the view zoom level (non-play mode).
/** @return: number*/let totalPages = await demo.PDFApplication().ActivePDF.PagesCount
/** @return: number*/let totalPages = await demo.PDFApplication().ActivePDF.CurrentPage
/** @param : { PageNum: number }*/let PageNum = 10await demo.PDFApplication().ActivePDF.JumpToPage({PageNum})
/** 1: Single-page mode* 0: Multi-page mode*/demo.PDFApplication().ActivePDF.PageMode = 1 // Set the single-page mode.
/** true: Show the table of contents* false: Hide the table of contents*/demo.PDFApplication().ActivePDF.DocumentMap = true // Show the table of contents.
/** @return: number*/await demo.PDFApplication().ActivePDF.Zoom // Read the view zoom level./** @param : 1 <= number <= 400 (The zoom level is between 1% and 400%.)*/demo.PDFApplication().ActivePDF.Zoom = 100 // Set the view zoom level.
on method of the instance to listen on events.demo.on('Event name', function(data) {// do something...})
Event | Description |
fileOpen | The file was opened successfully or failed to be opened. |
error | An error occurred, and an error code was returned. |
fileStatus | The file was saved, and a status value was returned. Valid values: 0 (the file had no updates); 1 (the version was saved successfully); 2 (the file was empty and couldn't be saved); 3 (the space was full); 4 (the file was being saved); 5 (the file failed to be saved); 6 (the file updates were being saved; this status will be triggered when the file content is modified); 7 (the change to the file content was saved successfully). |
Apakah halaman ini membantu?
Anda juga dapat Menghubungi Penjualan atau Mengirimkan Tiket untuk meminta bantuan.
masukan