Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active September 21, 2022 07:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/af09ca4d792ab736163aa09d83488e85 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/af09ca4d792ab736163aa09d83488e85 to your computer and use it in GitHub Desktop.
Adjust Row Height and Column Width in Excel using Python
import jpype
import asposecells
jpype.startJVM()
from asposecells.api import Workbook
# Load Excel file
workbook = Workbook("source.xlsx")
# Access the first worksheet in the Excel file
worksheet = workbook.getWorksheets().get(0)
# Get cells collection
cells = worksheet.getCells()
# Set the height of the second column to 40
cells.setColumnWidth(1, 40)
# Save the updated Excel file
workbook.save("column-adjustment.xlsx")
import jpype
import asposecells
jpype.startJVM()
from asposecells.api import Workbook
# Load Excel file
workbook = Workbook("source.xlsx")
# Access the first worksheet in the Excel file
worksheet = workbook.getWorksheets().get(0)
# Get cells collection
cells = worksheet.getCells()
# Set the height of the second row to 50
cells.setRowHeight(1, 50)
# Save the updated Excel file
workbook.save("row-adjustment.xlsx")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment