Class ExcelAI
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
stringThe question to be answered.
enableHistory
boolFlag 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
stringThe question to be answered.
enableHistory
boolFlag 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
stringThe question to be searched.
file_server_path
stringThe file server path.
enableHistory
boolFlag 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
stringThe question to be searched.
file_server_path
stringQA for a file based on server-side path.
options
Dictionary<string, string>extra options.
enableHistory
boolFlag 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
stringThe question to be answered.
file_server_path
stringThe file server path.
enableHistory
boolFlag 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
stringThe question to be answered.
file_server_path
stringThe file server path.
options
Dictionary<string, string>extra options.
enableHistory
boolFlag 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
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
CellRangeThe range of cells containing the data to fill.
descRange
CellRangeThe range of cells containing the description for each column.
containTitle
boolA 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
CellRangeThe range of cells containing the data to fill.
descRange
CellRangeThe range of cells containing the description for each column.
containTitle
boolA 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
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
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
CellRangeThe destination range.
srcRanges
List<CellRange>The ranges containing the data to merge.
titleRange
CellRangeThe 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
CellRangeThe destination range.
srcRanges
List<CellRange>The ranges containing the data to merge.
titleRange
CellRangeThe 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
stringThe 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
stringThe target language for translation.
translateSheetName
boolA 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
stringThe 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
stringThe target language for translation.
translateSheetName
boolA 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
ImageGenerate(string)
Generate images from text using AI.
public Stream ImageGenerate(string description)
Parameters
description
stringtext 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
stringtext description about image.
model
ImageGenarationModelImage Models for generation.
size
ImageGenarationSizeImage 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
stringtext 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
stringtext description about image.
model
ImageGenarationModelImage Models for generation.
size
ImageGenarationSizeImage 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
stringthe 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
stringthe 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
stringQuestions asked.
language
stringlanguage of answer.
enableHistory
boolFlag 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
stringThe question to be answered.
language
stringlanguage of answer.
enableHistory
boolFlag 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
stringThe name of the file to be uploaded.
stream
StreamThe 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
stringThe name of the file to be uploaded.
stream
StreamThe 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
Workbookworkbook.
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
Workbookworkbook.