Table of Contents

Class ExcelAI

Namespace
Spire.Xls.AI
Assembly
Spire.XLS.dll
public class ExcelAI : SpireAI
Inheritance
ExcelAI
Inherited Members

Constructors

ExcelAI()

Initializes a new instance of the ExcelAI class.

public ExcelAI()

Methods

Ask(string, bool)

Performs a question-asking task using AI.

public string Ask(string question, bool enableHistory = false)

Parameters

question string

The question to be answered.

enableHistory bool

Flag indicating whether to enable chat history.

Returns

string

result contains the generated answer as a string.

AskAsync(string, bool)

Performs a question-asking task using AI.

public Task<string> AskAsync(string question, bool enableHistory = false)

Parameters

question string

The question to be answered.

enableHistory bool

Flag indicating whether to enable chat history.

Returns

Task<string>

A task that represents the asynchronous operation. The task result contains the generated answer as a string.

DocumentSearch(string, string, bool)

Performs a question-searching task using the AI service with the specified question, for a file based on server-side path.

public string DocumentSearch(string question, string file_server_path, bool enableHistory = false)

Parameters

question string

The question to be searched.

file_server_path string

The file server path.

enableHistory bool

Flag indicating whether to enable chat history.

Returns

string

result contains the generated answer as a string.

DocumentSearch(string, string, Dictionary<string, string>, bool)

Performs a question-searching task using the AI service with the specified question.

public string DocumentSearch(string question, string file_server_path = null, Dictionary<string, string> options = null, bool enableHistory = false)

Parameters

question string

The question to be searched.

file_server_path string

QA for a file based on server-side path.

options Dictionary<string, string>

extra options.

enableHistory bool

Flag indicating whether to enable chat history.

Returns

string

result contains the generated answer as a string.

DocumentSearchAsync(string, string, bool)

Performs a question-searching task using the AI service with the specified question, for a file based on server-side path.

public Task<string> DocumentSearchAsync(string question, string file_server_path, bool enableHistory = false)

Parameters

question string

The question to be answered.

file_server_path string

The file server path.

enableHistory bool

Flag indicating whether to enable chat history.

Returns

Task<string>

A task that represents the asynchronous operation. The task result contains the generated answer as a string.

DocumentSearchAsync(string, string, Dictionary<string, string>, bool)

Performs a question-searching task using the AI service with the specified question, for a file based on server-side path.

public Task<string> DocumentSearchAsync(string question, string file_server_path, Dictionary<string, string> options = null, bool enableHistory = false)

Parameters

question string

The question to be answered.

file_server_path string

The file server path.

options Dictionary<string, string>

extra options.

enableHistory bool

Flag indicating whether to enable chat history.

Returns

Task<string>

A task that represents the asynchronous operation. The task result contains the generated answer as a string.

ExcelAIGenarateAsync(List<CellRange>)

Generates AI-based responses for Excel data processing.

public Task<string> ExcelAIGenarateAsync(List<CellRange> srcRanges)

Parameters

srcRanges List<CellRange>

The list of CellRanges representing the input data.

Returns

Task<string>

An async task that returns a string indicating whether the processing was successful or not.

ExcelFill(CellRange, CellRange, bool, List<int>, List<string>)

Fills the Excel worksheet with data extracted from the specified data range, using the specified description range, column indexes, and keys.

public string ExcelFill(CellRange dataRange, CellRange descRange, bool containTitle, List<int> fillColumnIndexs, List<string> keys = null)

Parameters

dataRange CellRange

The range of cells containing the data to fill.

descRange CellRange

The range of cells containing the description for each column.

containTitle bool

A boolean value indicating whether the data range contains a title row.

fillColumnIndexs List<int>

A list of column indexes in the data range to fill.

keys List<string>

An optional list of keys to extract specific information from the data. If null, the function will extract information based on the description range.

Returns

string

A string indicating the status of the operation.

Exceptions

ApiException

Thrown when any of the parameters is null or invalid.

ExcelFillAsync(CellRange, CellRange, bool, List<int>, List<string>)

Fills the Excel worksheet with data extracted from the specified data range, using the specified description range, column indexes, and keys.

public Task<string> ExcelFillAsync(CellRange dataRange, CellRange descRange, bool containTitle, List<int> fillColumnIndexs, List<string> keys = null)

Parameters

dataRange CellRange

The range of cells containing the data to fill.

descRange CellRange

The range of cells containing the description for each column.

containTitle bool

A boolean value indicating whether the data range contains a title row.

fillColumnIndexs List<int>

A list of column indexes in the data range to fill.

keys List<string>

An optional list of keys to extract specific information from the data. If null, the function will extract information based on the description range.

Returns

Task<string>

An async task that returns a string indicating the status of the operation.

Exceptions

ApiException

Thrown when any of the parameters is null or invalid.

ExcelGenerate(List<CellRange>)

Generates AI-based responses for Excel data processing.

public string ExcelGenerate(List<CellRange> srcRanges)

Parameters

srcRanges List<CellRange>

The list of CellRanges representing the input data.

Returns

string

a string indicating whether the processing was successful or not.

ExcelMerge(CellRange, List<CellRange>, CellRange)

Merges the data from multiple range into a destination range using AI. Limited by the reasoning ability of AI, the processing results of irregular data may not be ideal. The amount of data processed is alos limited

public string ExcelMerge(CellRange descRange, List<CellRange> srcRanges, CellRange titleRange)

Parameters

descRange CellRange

The destination range.

srcRanges List<CellRange>

The ranges containing the data to merge.

titleRange CellRange

The range containing the title.

Returns

string

a string indicating whether the processing was successful or not.

ExcelMergeAsync(CellRange, List<CellRange>, CellRange)

Merges the data from multiple range into a destination range using AI. Limited by the reasoning ability of AI, the processing results of irregular data may not be ideal. The amount of data processed is alos limited

public Task<string> ExcelMergeAsync(CellRange descRange, List<CellRange> srcRanges, CellRange titleRange)

Parameters

descRange CellRange

The destination range.

srcRanges List<CellRange>

The ranges containing the data to merge.

titleRange CellRange

The range containing the title.

Returns

Task<string>

An async task that returns a string indicating whether the processing was successful or not.

ExcelTranslate(List<CellRange>, string)

Translates the text within the specified cell ranges using AI.

public string ExcelTranslate(List<CellRange> srcRanges, string language)

Parameters

srcRanges List<CellRange>

The list of CellRanges representing the source data.

language string

The target language for translation.

Returns

string

a string indicating whether the processing was successful or not.

ExcelTranslate(List<Worksheet>, string, bool)

Translates the text within the specified worksheets using AI.

public string ExcelTranslate(List<Worksheet> srcWorksheets, string language, bool translateSheetName = true)

Parameters

srcWorksheets List<Worksheet>

The list of Worksheets representing the source data.

language string

The target language for translation.

translateSheetName bool

A boolean indicating whether to translate the sheet names.

Returns

string

a string indicating whether the processing was successful or not.

ExcelTranslateAsync(List<CellRange>, string)

Translates the text within the specified cell ranges using AI.

public Task<string> ExcelTranslateAsync(List<CellRange> srcRanges, string language)

Parameters

srcRanges List<CellRange>

The list of CellRanges representing the source data.

language string

The target language for translation.

Returns

Task<string>

An async task that returns a string indicating whether the processing was successful or not.

ExcelTranslateAsync(List<Worksheet>, string, bool)

Translates the text within the specified worksheets using AI.

public Task<string> ExcelTranslateAsync(List<Worksheet> srcWorksheets, string language, bool translateSheetName = true)

Parameters

srcWorksheets List<Worksheet>

The list of Worksheets representing the source data.

language string

The target language for translation.

translateSheetName bool

A boolean indicating whether to translate the sheet names.

Returns

Task<string>

An async task that returns a string indicating whether the processing was successful or not.

GetAppKey()

protected override string GetAppKey()

Returns

string

ImageGenerate(string)

Generate images from text using AI.

public Stream ImageGenerate(string description)

Parameters

description string

text description about image.

Returns

Stream

the stream of the Image.

ImageGenerate(string, ImageGenarationModel, ImageGenarationSize)

Generate images from text using AI.

public Stream ImageGenerate(string description, ImageGenarationModel model, ImageGenarationSize size)

Parameters

description string

text description about image.

model ImageGenarationModel

Image Models for generation.

size ImageGenarationSize

Image Size for generation.

Returns

Stream

the stream of the Image.

ImageGenerateAsync(string)

Generate images from text using AI.

public Task<Stream> ImageGenerateAsync(string description)

Parameters

description string

text description about image.

Returns

Task<Stream>

A task that represents the asynchronous operation. The task result contains the stream of the Image.

ImageGenerateAsync(string, ImageGenarationModel, ImageGenarationSize)

Generate images from text using AI.

public Task<Stream> ImageGenerateAsync(string description, ImageGenarationModel model, ImageGenarationSize size)

Parameters

description string

text description about image.

model ImageGenarationModel

Image Models for generation.

size ImageGenarationSize

Image Size for generation.

Returns

Task<Stream>

A task that represents the asynchronous operation. The task result contains the stream of the Image.

ResetChatHistory(string)

Resets the chat history in the AI service.

public string ResetChatHistory(string sessionid)

Parameters

sessionid string

the id of chat session.

Returns

string

a string indicating whether the processing was successful or not.

ResetChatHistoryAsync(string)

Resets the chat history in the AI service.

public Task<string> ResetChatHistoryAsync(string sessionid)

Parameters

sessionid string

the id of chat session.

Returns

Task<string>

An async task that returns a string indicating whether the processing was successful or not.

ResetUserHistory()

Resets the user's all chat history in the AI service.

public string ResetUserHistory()

Returns

string

a string indicating whether the processing was successful or not.

ResetUserHistoryAsync()

Resets the user's all chat history in the AI service.

public Task<string> ResetUserHistoryAsync()

Returns

Task<string>

An async task that returns a string indicating whether the processing was successful or not.

Search(string, string, bool)

Ask a question using AI.

public string Search(string question, string language, bool enableHistory = false)

Parameters

question string

Questions asked.

language string

language of answer.

enableHistory bool

Flag indicating whether to enable chat history.

Returns

string

result contains the generated answer as a string.

SearchAsync(string, string, bool)

Performs a question-searching task using AI.

public Task<string> SearchAsync(string question, string language, bool enableHistory = false)

Parameters

question string

The question to be answered.

language string

language of answer.

enableHistory bool

Flag indicating whether to enable chat history.

Returns

Task<string>

A task that represents the asynchronous operation. The task result contains the generated answer as a string.

UploadFile(string, Stream)

Uploads a file to the AI service.

public string UploadFile(string fileName, Stream stream)

Parameters

fileName string

The name of the file to be uploaded.

stream Stream

The stream containing the file data.

Returns

string

result contains the file path on ai server as a string.

UploadFileAsync(string, Stream)

Uploads a file to the AI service.

public Task<string> UploadFileAsync(string fileName, Stream stream)

Parameters

fileName string

The name of the file to be uploaded.

stream Stream

The stream containing the file data.

Returns

Task<string>

A task that represents the asynchronous operation. The task result contains the file path on ai server as a string.

UploadWorkbook(Workbook)

Uploads workbook to the AI service.

public string UploadWorkbook(Workbook workbook)

Parameters

workbook Workbook

workbook.

Returns

string

A result contains the file path on ai server as a string.

UploadWorkbookAsync(Workbook)

Uploads workbook to the AI service.

public Task<string> UploadWorkbookAsync(Workbook workbook)

Parameters

workbook Workbook

workbook.

Returns

Task<string>

A task that represents the asynchronous operation. The task result contains the file path on ai server as a string.