Test in a live environment
Test in production without watermarks.
Works wherever you need it to.
from ironxl import *
# Supported for XLSX, XLS, XLSM, XLTX, CSV, and TSV
workbook = WorkBook.Load("sample.xlsx")
# Select worksheet at index 0
worksheet = workbook.WorkSheets[0]
# Get any existing worksheet
first_sheet = workbook.DefaultWorkSheet
# Select a cell and return the converted value
cell_value = worksheet["A2"].IntValue
# Read from ranges of cells elegantly.
for cell in worksheet["A2:A10"]:
print("Cell {} has value '{}'".format(cell.AddressString, cell.Text))
# Calculate aggregate values such as Min, and Sum
total_sum = worksheet["A2:A10"].Sum()
from ironxl import *
# Create new Excel WorkBook document
workbook = WorkBook.Create()
# Convert XLSX to XLS
xlsWorkBook = WorkBook.Create(ExcelFileFormat.XLS)
# Create a blank WorkSheet
worksheet = workbook.CreateWorkSheet("new_sheet")
# Add data and styles to the new worksheet
worksheet["A1"].Value = "Hello World"
worksheet["A1"].Style.WrapText = True
worksheet["A2"].BoolValue = True
worksheet["A2"].Style.BottomBorder.Type = BorderType.Double
# Save the excel file as XLS, XLSX, CSV, TSV, JSON, XML, HTML and streams
workbook.SaveAs("test.xlsx")
from ironxl import *
# Import any XLSX, XLS, XLSM, XLTX, CSV, and TSV
workbook = WorkBook.Load("sample.xlsx")
# Export the excel file as XLS, XLSX, XLSM, CSV, TSV, JSON, XML
workbook.SaveAs("sample.xls")
workbook.SaveAs("sample.xlsx")
workbook.SaveAs("sample.tsv")
workbook.SaveAsCsv("sample.csv")
workbook.SaveAsJson("sample.json")
workbook.SaveAsXml("sample.xml")
# Export the excel file as HTML, HTML string
workbook.ExportToHtml("sample.html")
html_string = workbook.ExportToHtmlString()
# Export the excel file as Binary, Byte array, Data set, Stream
binary_data = workbook.ToBinary()
byte_array_data = workbook.ToByteArray()
from ironxl import *
# Load existing spreadsheet
workbook = WorkBook.Load("sample.xlsx")
worksheet = workbook.DefaultWorkSheet
# Create conditional formatting rule
rule = worksheet.ConditionalFormatting.CreateConditionalFormattingRule(ComparisonOperator.LessThan, "8")
# Set style options
rule.FontFormatting.IsBold = True
rule.FontFormatting.FontColor = "#123456"
rule.BorderFormatting.RightBorderColor = "#ffffff"
rule.BorderFormatting.RightBorderType = BorderType.Thick
rule.PatternFormatting.BackgroundColor = "#54bdd9"
rule.PatternFormatting.FillPattern = FillPattern.Diamonds
# Apply formatting on the specified region
worksheet.ConditionalFormatting.AddConditionalFormatting("A3:A8", rule)
# Create another conditional formatting rule
rule1 = worksheet.ConditionalFormatting.CreateConditionalFormattingRule(ComparisonOperator.Between, "7", "10")
# Set style options
rule1.FontFormatting.IsItalic = True
rule1.FontFormatting.UnderlineType = FontUnderlineType.Single
# Apply formatting on the specified region
worksheet.ConditionalFormatting.AddConditionalFormatting("A3:A9", rule1)
# Save changes with applied conditional formatting
workbook.SaveAs("applyConditionalFormatting.xlsx")
from ironxl import *
# Load the Excel workbook
workbook = WorkBook.Load("sample.xlsx")
worksheet = workbook.DefaultWorkSheet
# Open a protected spreadsheet file
protected_workbook = WorkBook.Load("sample.xlsx", "IronSoftware")
# Spreadsheet protection
# Set protection for the spreadsheet file
workbook.Encrypt("IronSoftware")
# Remove protection for the spreadsheet file. Original password is not required.
workbook.Password = None
workbook.Save()
# Worksheet protection
# Set protection for an individual worksheet
worksheet.ProtectSheet("IronXL")
# Remove protection for a particular worksheet. It works without a password!
worksheet.UnprotectSheet()
workbook.Save()
from ironxl import *
# Load the Excel workbook
workbook = WorkBook.Load("sample.xlsx")
worksheet = workbook.DefaultWorkSheet
# Set Formulas
worksheet["A1"].Formula = "Sum(B8:C12)"
worksheet["B8"].Formula = "=C9/C11"
worksheet["G30"].Formula = "Max(C3:C7)"
# Force recalculate all formula values in all sheets.
workbook.EvaluateAll()
# Get the formula's calculated value. e.g. "52"
formula_value = worksheet["G30"].ToArray()[0].FormattedCellValue
# Get the formula as a string. e.g. "Max(C3:C7)"
formula_string = worksheet["G30"].Formula
# Save changes with updated formulas and calculated values.
workbook.Save()
from ironxl import *
# Load the Excel workbook
workbook = WorkBook.Load("sample.xlsx")
# Set author
workbook.Metadata.Author = "Your Name"
# Set comments
workbook.Metadata.Comments = "Monthly report"
# Set title
workbook.Metadata.Title = "July"
# Set keywords
workbook.Metadata.Keywords = "Report"
# Read the creation date of the Excel file
creation_date = workbook.Metadata.Created
# Read the last printed date of the Excel file
print_date = workbook.Metadata.LastPrinted
# Save the workbook with edited metadata
workbook.SaveAs("editedMetadata.xlsx")
from ironxl import *
# Load existing spreadsheet
workbook = WorkBook.Load("sample.xls")
worksheet = workbook.WorkSheets[0]
# Get a range from an Excel worksheet
selected_range = worksheet["A1:H10"]
# Get the first cell in the range
cell = selected_range.ToArray()[0]
# Set background color of the cell with an RGB string
cell.Style.SetBackgroundColor("#428D65")
# Apply styling to the whole range
# Set underline property to the font
# FontUnderlineType is an enum that stands for different types of font underline
selected_range.Style.Font.Underline = FontUnderlineType.SingleAccounting
# Define whether to use a horizontal line through the text or not
selected_range.Style.Font.Strikeout = False
# Define whether the font is bold or not
selected_range.Style.Font.Bold = True
# Define whether the font is italic or not
selected_range.Style.Font.Italic = False
# Get or set the script property of a font
# FontScript enum stands for available options
selected_range.Style.Font.FontScript = FontScript.Super
# Set the type of the border line
# There are also TopBorder, LeftBorder, RightBorder, DiagonalBorder properties
# BorderType enum indicates the line style of a border in a cell
selected_range.Style.BottomBorder.Type = BorderType.MediumDashed
# Indicate whether the cell should be auto-sized
selected_range.Style.ShrinkToFit = True
# Set alignment of the cell
selected_range.Style.VerticalAlignment = VerticalAlignment.Bottom
# Set border color
selected_range.Style.DiagonalBorder.SetColor("#20C96F")
# Define border type and border direction as well
selected_range.Style.DiagonalBorder.Type = BorderType.Thick
# DiagonalBorderDirection enum stands for direction of diagonal border inside cell
selected_range.Style.DiagonalBorderDirection = DiagonalBorderDirection.Forward
# Set background color of cells
selected_range.Style.SetBackgroundColor(Color.Aquamarine)
# Set fill pattern of the cell
# FillPattern enum indicates the style of fill pattern
selected_range.Style.FillPattern = FillPattern.Diamonds
# Set the number of spaces to indent the text
selected_range.Style.Indention = 5
# Indicate if the text is wrapped
selected_range.Style.WrapText = True
# Save changes with applied styling options
workbook.SaveAs("stylingOptions.xls")
from ironxl import *
# Load the Excel workbook
workbook = WorkBook.Load("sample.xlsx")
worksheet = workbook.DefaultWorkSheet
# Select a range
selected_range = worksheet["A1:D20"]
# Select a column(B)
column = worksheet.GetColumn(1)
# Sort the range in ascending order (A to Z)
selected_range.SortAscending()
# Sort the range by column(C) in ascending order
selected_range.SortByColumn("C", SortOrder.Ascending)
# Sort the column(B) in descending order (Z to A)
column.SortDescending()
# Save changes with the sorted range and column
workbook.SaveAs("sortExcelRange.xlsx")
from ironxl import *
# Load existing spreadsheet
workbook = WorkBook.Load("sample.xlsx")
worksheet = workbook.DefaultWorkSheet
# Set repeating rows for row(2-4)
worksheet.SetRepeatingRows(1, 3)
# Set repeating columns for column(C-D)
worksheet.SetRepeatingColumns(2, 3)
# Set column break after column(H). Hence, the first page will only contain column(A-G)
worksheet.SetColumnBreak(7)
# Save changes with repeating rows and columns
workbook.SaveAs("repeatingRows.xlsx")
Designed for Python 3+ running on Windows, Mac, Linux or Cloud Platforms.
Available for .NET & Python
IronXL for Python is the leading Python Excel library for generating and editing Excel documents. Its user friendly API allows developers to add Excel functionality to Python projects in minutes.
pip install IronXL-2024.9-py37-none-win_amd64.whi
Have a question? Get in touch with our development team.
Want to deploy IronXL to a live project for FREE?
Your trial key should be in the email.The trial form was submitted
successfully.
If it is not, please contact
support@ironsoftware.com
Want to deploy IronXL to a live project for FREE?
Your trial key should be in the email.The trial form was submitted
successfully.
If it is not, please contact
support@ironsoftware.com
Want to deploy IronXL to a live project for FREE?
Your trial key should be in the email.The trial form was submitted
successfully.
If it is not, please contact
support@ironsoftware.com
Want to deploy IronXL to a live project for FREE?
Your trial key should be in the email.The trial form was submitted
successfully.
If it is not, please contact
support@ironsoftware.com
Get started for FREE
No credit card required
Test in production without watermarks.
Works wherever you need it to.
Get 30 days of fully functional product.
Have it up and running in minutes.
Full access to our support engineering team during your product trial
No credit card or account creation required
Your trial key should be in the email.
If it is not, please contact
support@ironsoftware.com
Get started for FREE
No credit card required
Test in production without watermarks.
Works wherever you need it to.
Get 30 days of fully functional product.
Have it up and running in minutes.
Full access to our support engineering team during your product trial
No credit card or account creation required
Your trial key should be in the email.
If it is not, please contact
support@ironsoftware.com
Get started for FREE
No credit card required
Test in production without watermarks.
Works wherever you need it to.
Get 30 days of fully functional product.
Have it up and running in minutes.
Full access to our support engineering team during your product trial
Licenses from $749. Have a question? Get in touch.
Thank you!
Your license key has been delivered to the email provided.Contact us
24-Hour Upgrade Offer:
Save 50% on a
Professional Upgrade
Go Professional to cover 10 developers
and unlimited projects.
:
:
Professional
$600 USD
$299 USD
5 .NET Products for the Price of 2
Total Suite Value:
$7,192 USD
Upgrade price
TODAY
ONLY
$499 USD
After 24 Hrs
$1,098 USD
Fully-functional product, get the key instantly
9 .NET API products for your office documents