row_count
row_count()
Description
Retrieves the number of rows in the table.
Return value
The number of rows.<int>
Example rpa.app.microsoft.word.Table.row_count
# Note: Make sure the required Microsoft software is installed before use.
# Example:
word_file_path = r"D:\2_TestFileArchive\TestWord.docx"
word = rpa.app.microsoft.word.open(word_file_path, visible=True)
table = word.get_table(1)
row_count = table.row_count()col_count
col_count()
Description
Retrieves the number of columns in the table.
Return value
The number of columns.<int>
Example rpa.app.microsoft.word.Table.col_count
# Note: Make sure the required Microsoft software is installed before use.
# Example:
word_file_path = r"D:\2_TestFileArchive\TestWord.docx"
word = rpa.app.microsoft.word.open(word_file_path, visible=True)
table = word.get_table(1)
col_count = table.col_count()read
read(row, col)
Description
Retrieves the content of a specified cell.
Parameters
row<int> The row number.
col<int> The column number.
Return value
The content of the specified cell.<str>
Example rpa.app.microsoft.word.Table.read
# Note: Make sure the required Microsoft software is installed before use.
# Example:
word_file_path = r"D:\2_TestFileArchive\TestWord.docx"
word = rpa.app.microsoft.word.open(word_file_path, visible=True)
table = word.get_table(1)
data = table.read(1,1)write
write(row, col, text, size=8, family='Microsoft YaHei', color=1)
Description
Writes content to a specified cell.
Parameters
row<int> The row number.
col<int> The column number.
text<str> The content to write.
size<int> The font size.
family<str> The font family.
color<int> The font color code.
Example rpa.app.microsoft.word.Table.write
# Note: Make sure the required Microsoft software is installed before use.
# When you write to the table, make sure the row and column parameters do not exceed the table's dimensions.
# Example:
word_file_path = r"D:\2_TestFileArchive\TestWord.docx"
word = rpa.app.microsoft.word.open(word_file_path, visible=True)
table = word.get_table(1)
text = "RPA_WORD_document_table_write_test"
table.write(1,1,text)merge_cell
merge_cell (start_cell_row, start_cell_col, end_cell_row, end_cell_col)
Description
Merges cells.
Parameters
start_cell_row<int> The row number of the starting cell.
start_cell_col<int> The column number of the starting cell.
end_cell_row<int> The row number of the ending cell.
end_cell_col<int> The column number of the ending cell.
Example rpa.app.microsoft.word.Table.merge_cell
# Note: Make sure the required Microsoft software is installed before use.
# Example:
word_file_path = r"D:\2_TestFileArchive\TestWord.docx"
word = rpa.app.microsoft.word.open(word_file_path, visible=True)
table = word.get_table(1)
# Merges the cells from row 2, column 2 to row 5, column 3.
table.merge_cell(2,2,5,3)select_cell
select_cell (row, col)
Description
Selects a cell.
Parameters
row<int> The row number.
col<int> The column number.
Example rpa.app.microsoft.word.Table.select_cell
# Note: Make sure the required Microsoft software is installed before use.
# Example:
word_file_path = r"D:\2_TestFileArchive\TestWord.docx"
word = rpa.app.microsoft.word.open(word_file_path, visible=True)
table = word.get_table(1)
# Selects the cell at row 2, column 3.
table.select_cell(2,3)set_row_height
set_row_height (row, height)
Description
Sets the row height.
Parameters
row<int> The row number.
height<int> The row height.
Example rpa.app.microsoft.word.Table.set_row_height
# Note: Make sure the required Microsoft software is installed before use.
# Example:
word_file_path = r"D:\2_TestFileArchive\TestWord.docx"
word = rpa.app.microsoft.word.open(word_file_path, visible=True)
table = word.get_table(1)
# Sets the height of the second row to 50.
table.set_row_height(2,50)set_col_width
set_col_width (col, width)
Description
Sets the column width.
Parameters
row <int> The row number.
width<int> The column width.
Example rpa.app.microsoft.word.Table.set_col_width
# Note: Make sure the required Microsoft software is installed before use.
# Example:
word_file_path = r"D:\2_TestFileArchive\TestWord.docx"
word = rpa.app.microsoft.word.open(word_file_path, visible=True)
table = word.get_table(1)
# Sets the width of the second column to 100.
table.set_col_width(2,100)delete
delete ()
Description
Deletes this table.
Example rpa.app.microsoft.word.Table.delete
# Note: Make sure the required Microsoft software is installed before use.
# Example:
word_file_path = r"D:\2_TestFileArchive\TestWord.docx"
word = rpa.app.microsoft.word.open(word_file_path, visible=True)
table = word.get_table(1)
# Deletes this table.
table.delete()add_row
add_row()
Description
Add an empty line.
Example: rpa.app.microsoft.word.Table.add_row
# Note: Make sure the required Microsoft software is installed before use.
# Adds a new row to the end of the table by default.
# Example:
word_file_path = r"D:\2_TestFileArchive\TestWord.docx"
word = rpa.app.microsoft.word.open(word_file_path, visible=True)
table = word.get_table(1)
table.add_row()add_col
add_col()
Description
Adds an empty column.
Example rpa.app.microsoft.word.Table.add_col
# Note: Make sure the required Microsoft software is installed before use.
# Adds a new column to the right side of the table by default.
# Example:
word_file_path = r"D:\2_TestFileArchive\TestWord.docx"
word = rpa.app.microsoft.word.open(word_file_path, visible=True)
table = word.get_table(1)
table.add_col()