[Python] Change one word in specific row in Excel file using Python

Discussão em 'Python' iniciado por Stack, Maio 15, 2025.

  1. Stack

    Stack Membro Participativo

    I found out how to change text in Excel file with Aspose.Cells for Python through Java:

    import jpype
    import asposecells
    jpype.startJVM()
    from asposecells.api import *

    import os
    os.chdir(r"c:\Users\Manager\Desktop")
    os.getcwd()
    workbook = Workbook('Invoice.xlsx')

    # Create replace options
    replace = ReplaceOptions()


    # Set case sensitivity and text matching options
    replace.setCaseSensitive(False)
    replace.setMatchEntireCellContents(False)



    # Replace text
    workbook.replace("one","two", replace)
    workbook.replace("one","five", replace)




    workbook.save("Invoice 2.xlsx");


    But I need to replace "one" in first row to "two", "one" in tenth row to "five". As you see, first replacement affects on all file. How can I fix it?

    Continue reading...

Compartilhe esta Página