Print a pattern of text based on a line from an Excel file
STYLING
According to PEP-8, there are a few improvements to be made to your code:

Imports: Your imports should go in alphabetical order
Variable/Function Names: You should use snake_case instead of camelCase
Parameter Names: This may just be how I view your code, but how your parameters are named look like your taking in objects. You should use lowercase variables for better readability.
Spacing: You should use 4 spaces for each indent. For variable declaration and assignment, the = should be separated by a space on each side for readability, like so: s=0 to s = 0.
Main Guard: You should wrap any regular code in a if 'name == 'main' guard, to make sure that the code is only being run when that file is the main file, and not being imported by anything.

STRING FORMATTING
All throughout your code, you put strings together using + and .format. Luckily there is an easier way, by putting an f before the string like so: f&quot;content here&quot;. This erases the need to have verbose + in your strings, and you no longer have to cast int to str with this method, you can just write the code in the brackets {your code here}.
Example:
return &quot;name &quot; + '&quot;{}&quot;'.format(cell_content)
to
return f&quot;name \&quot;{cell_content}\&quot;&quot;
Here is the updated code:
import re
import xlrd

loc = (&quot;Dir\StackoverflowExample.xlsx&quot;)

wb = xlrd.open_workbook(loc) 
sheet = wb.sheet_by_index(0) 
sheet.cell_value(0, 0) 

# Extracting number of rows 

def case_multi(cell_content, cell_name):
    #takes a cell and a string as parameters, prints a pattern like Cell.X =&quot;string&quot;, X starts with 0 and ends at the number of line in the Cell
    case = str(cell_content)  
    x = re.split (&quot;\s&quot;, case)   #splits the cell contents in a list using regex where space is the separator for the list's elements
    if name == cell_content:  # deals with the cell with spaces between objects no clue how it work but it does
        return f&quot;name \&quot;{cell_content}\&quot;&quot;
    else:
        s = 0
        string = &quot;&quot; 
    if str(x[0]).lower() == &quot;any&quot;:
        return &quot; &quot; 
    else:
        if len(x) == 1: # case where the cell has one line (or a word with no spaces)
            string = f&quot;{cell_name} \&quot;{case}\&quot;&quot;
        else: # case where multilines/mutli spaces
            while s &lt; len(x):
                listelement = x[s]
                string += f&quot;{cell_name}.{str(s + 1)} \&quot;{listelement}\&quot;&quot;
                s += 1

        return string

def main():

    for number_of_rows in range(5):

        print &quot;Rule &quot; + str(number_of_rows)
        name= sheet.cell_value(number_of_rows, 1)
        source = sheet.cell_value(number_of_rows, 2)
        destination = sheet.cell_value(number_of_rows, 3)
        protocole = sheet.cell_value(number_of_rows, 4)
        log = sheet.cell_value(number_of_rows, 5)
        action = sheet.cell_value(number_of_rows, 6)
        #firewall = sheet.cell_value(number_of_rows, 7)

        try:
            print (&quot;mgmt_cli add access-rule layer \&quot;network\&quot; position bottom &quot; + str(case_multi(name,&quot;name&quot;)) +  str(case_multi(source, &quot; source&quot;)) + str(case_multi(destination, &quot; destination&quot;)) +  str(case_multi(protocole, &quot; service&quot;)) +   ' track.type &quot;Log&quot; ' + str(case_multi(action, &quot; action&quot;)) )
        except:
            number_of_rows += 1

if __name__ == '__main__':
    main()