|
| 1 | +import os |
| 2 | + |
| 3 | +from asposecellscloud.apis.cells_api import CellsApi |
| 4 | +from asposecellscloud.models import * |
| 5 | +from asposecellscloud.requests import * |
| 6 | + |
| 7 | +# If no environment variables are configured, please obtain the ClientId and ClientSecret from https://dashboard.aspose.cloud/#/applications and replace the following values: |
| 8 | +# instance = CellsApi('YourClientId','YourClientSecret') |
| 9 | +instance = CellsApi(os.getenv('CellsCloudClientId'),os.getenv('CellsCloudClientSecret')) |
| 10 | + |
| 11 | +# The default value of the trim character is a blank space. Specify a specific location. Remove excess spaces between words. |
| 12 | +instance.trim_character(TrimCharacterRequest("BookText.xlsx", worksheet = "HumanResources", range ="A1:C12" , trim_space_between_word_to1 = True) ,local_outpath = "out1.xlsx") |
| 13 | +# The default value of the trim character is a blank space. Specify a specific location. Remove excess spaces between words. Only remove leading spaces. |
| 14 | +instance.trim_character(TrimCharacterRequest("BookText.xlsx", worksheet = "Text", range ="J6:J6" ,trim_trailing = False, trim_space_between_word_to1 = True) ,local_outpath = "out2.xlsx") |
| 15 | +# The default value of the trim character is a blank space. Specify a specific location. Remove excess spaces between words. Only remove leading spaces. Remove all line breaks. |
| 16 | +instance.trim_character(TrimCharacterRequest("BookText.xlsx", worksheet = "Text", range ="J7:J7" ,trim_trailing = False, trim_space_between_word_to1 = True,remove_all_line_breaks =True) ,local_outpath = "out3.xlsx") |
| 17 | +# Uppercase every string in the selected range. |
| 18 | +instance.update_word_case(UpdateWordCaseRequest("BookText.xlsx", "UpperCase", worksheet = "Text", range ="J7:J7" ) , local_outpath = "out4.xlsx") |
| 19 | +# Lowercase every string in the selected range. |
| 20 | +instance.update_word_case(UpdateWordCaseRequest("out4.xlsx", "LowerCase", worksheet = "Text", range ="J7:J7" ) , local_outpath = "out5.xlsx") |
| 21 | +# ProperCase every string in the selected range. |
| 22 | +instance.update_word_case(UpdateWordCaseRequest("out5.xlsx", "ProperCase", worksheet = "Text", range ="J7:J7" ) , local_outpath = "out6.xlsx") |
| 23 | +# SentenceCase every string in the selected range. |
| 24 | +instance.update_word_case(UpdateWordCaseRequest("out5.xlsx", "SentenceCase", worksheet = "Text", range ="J7:J7" ) , local_outpath = "out7.xlsx") |
| 25 | + |
| 26 | +# Prefix every string in the selected range with "Aspose.Cells". |
| 27 | +instance.add_text( AddTextRequest("BookText.xlsx", "Aspose.Cells", "AtTheBeginning", "") , local_outpath = "out8.xlsx" ) |
| 28 | +# Insert an exclamation mark immediately after the specified substring within every string in the selected range. |
| 29 | +instance.add_text( AddTextRequest("BookText.xlsx", "!", "AfterText", "hellow word") , local_outpath = "out9.xlsx" ) |
| 30 | +# Append an exclamation mark to every string in the selected range. |
| 31 | +instance.add_text( AddTextRequest("BookText.xlsx", "!", "AtTheEnd", "", worksheet = "Text", range ="A1:J7" ,skip_empty_cells=False ) , local_outpath = "out10.xlsx" ) |
| 32 | + |
| 33 | +# convert_text_type: ConvertNumberToText,ConvertCharacters,ConvertLinebreak,ConvertWriteSpace,ConvertAccentedChars |
| 34 | +# Convert all numbers in the selected range to text. If worksheet and range are empty, the entire workbook is processed. |
| 35 | +instance.convert_text(ConvertTextRequest("BookText.xlsx", "ConvertNumberToText", "", ""), local_outpath = "out11.xlsx") |
| 36 | +# Replace every '1' in the selected range with 'Aspose.Cells'. If worksheet and range are empty, the entire workbook is processed. |
| 37 | +instance.convert_text(ConvertTextRequest("out11.xlsx", "ConvertCharacters", "1", "Aspose.Cells" , worksheet="Text", range="C9:F13"), local_outpath = "out12.xlsx") |
| 38 | +# Replace all line breaks in the selected range with the specified character. |
| 39 | +instance.convert_text(ConvertTextRequest("out12.xlsx", "ConvertLinebreak", "", "Linebreak"), local_outpath = "out13.xlsx") |
| 40 | +# Replace all blank space in the selected range with the specified character. |
| 41 | +instance.convert_text(ConvertTextRequest("out13.xlsx", "ConvertWriteSpace", "", "WriteSpace"), local_outpath = "out14.xlsx") |
| 42 | + |
| 43 | +# ExtractTextType: ExtractFirstCharacter, ExtractFirstWord, ExtractLastCharacter, ExtractLastWord, ExtractTextBefore, ExtractTextAfter, ExtractBetweenSpecifiedCharacters, ExtractAllNumbers, GetTextFromAnyPosition |
| 44 | +# |
| 45 | +# instance.extract_text(ExtractTextRequest("BookText.xlsx", "ExtractTextBefore", ";","","","","I2:I11" ,worksheet= "HumanResources",range="G2:G11" ) , local_outpath = "out15.xlsx") |
0 commit comments