### Complete Validation Setup Example Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/_autodocs/api-reference/data-validation.md A comprehensive example demonstrating the setup of number and date validations with labels and styling. Requires Spire.XLS and Spire.Common imports. ```python from spire.xls import * from spire.common import * workbook = Workbook() sheet = workbook.Worksheets[0] # Add labels sheet.Range["B11"].Text = "Input Number (1-100):" sheet.Range["B14"].Text = "Input Date:" sheet.Range["B17"].Text = "Input Text (max 50 chars):" # Number validation num_range = sheet.Range["B12"] num_range.DataValidation.AllowType = CellDataType.Decimal num_range.DataValidation.CompareOperator = ValidationComparisonOperator.Between num_range.DataValidation.Formula1 = "1" num_range.DataValidation.Formula2 = "100" num_range.DataValidation.ErrorMessage = "Please input a number between 1 and 100!" num_range.DataValidation.ShowError = True num_range.Style.KnownColor = ExcelColors.Gray25Percent # Date validation date_range = sheet.Range["B15"] date_range.DataValidation.AllowType = CellDataType.Date date_range.DataValidation.CompareOperator = ValidationComparisonOperator.Between date_range.DataValidation.Formula1 = "1/1/2024" date_range.DataValidation.Formula2 = "12/31/2024" date_range.DataValidation.ErrorMessage = "Please input a date in 2024!" date_range.DataValidation.ShowError = True date_range.DataValidation.AlertStyle = AlertStyleType.Warning date_range.Style.KnownColor = ExcelColors.Gray25Percent ``` -------------------------------- ### Complete Page Setup and Configuration Example Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/_autodocs/configuration.md A comprehensive example demonstrating the configuration of page orientation, paper size, margins, headers, footers, printing options, and converter settings before saving the workbook to PDF. ```python from spire.xls import * from spire.common import * # Create workbook workbook = Workbook() sheet = workbook.Worksheets[0] # Configure page setup sheet.PageSetup.Orientation = PageOrientation.Landscape sheet.PageSetup.PaperSize = PaperSize.A4 sheet.PageSetup.TopMargin = 0.5 sheet.PageSetup.BottomMargin = 0.5 sheet.PageSetup.LeftMargin = 1.0 sheet.PageSetup.RightMargin = 1.0 # Configure headers/footers sheet.PageSetup.LeftHeader = "Company Report" sheet.PageSetup.CenterHeader = "&D" # Current date sheet.PageSetup.RightHeader = "Page &P of &N" sheet.PageSetup.CenterFooter = "Confidential" # Configure printing sheet.PageSetup.PrintGridlines = True sheet.PageSetup.PrintRowColumnHeadings = True sheet.PageSetup.PrintArea = "$A$1:$H$50" # Configure converter settings for PDF workbook.ConverterSetting.SheetFitToPage = True workbook.ConverterSetting.TopMargin = 0.5 workbook.ConverterSetting.BottomMargin = 0.5 # Add data sheet.Range["A1"].Text = "Sample Report" sheet.Range["A1"].Style.Font.Size = 14 sheet.Range["A1"].Style.Font.IsBold = True # Save as PDF with settings workbook.SaveToFile("configured_report.pdf", FileFormat.PDF) workbook.Dispose() ``` -------------------------------- ### Practical Examples Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/_autodocs/api-reference/chart.md Includes practical examples of chart creation and configuration, such as a column chart with a dual axis. ```APIDOC ## Practical Examples ### Column Chart with Dual Axis ```python from spire.xls import Workbook, ChartType workbook = Workbook() sheet = workbook.Worksheets[0] # Sample data headers = ["Q1", "Q2", "Q3", "Q4"] sales = [100, 150, 120, 200] growth = [5, 10, 8, 15] # Add headers for col, header in enumerate(headers, 1): sheet.Range[1, col].Text = header ``` ``` -------------------------------- ### Access Worksheet for Header/Footer Setup in Spire.XLS Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/Python Examples/xls_python.md This is a minimal example showing how to get the first worksheet object from a workbook, which is a prerequisite for setting up headers and footers using Spire.XLS for Python. ```python # Get the first worksheet Worksheet = workbook.Worksheets[0] ``` -------------------------------- ### Configure Page Setup Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/_autodocs/api-reference/worksheet.md Sets basic page setup properties such as top and bottom margins, and page orientation. Requires the `PageOrientation` enum. ```python sheet.PageSetup.TopMargin = 0.5 sheet.PageSetup.BottomMargin = 0.5 sheet.PageSetup.Orientation = PageOrientation.Landscape ``` -------------------------------- ### TableBuiltInStyles Usage Example Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/_autodocs/types.md Shows how to apply a built-in style to an Excel table. This example sets the table to use the 'Light 9' style. ```python table.BuiltInTableStyle = TableBuiltInStyles.TableStyleLight9 ``` -------------------------------- ### Create a 3D Line Chart Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/Python Examples/xls_python.md This example demonstrates the creation of a 3D line chart. It includes settings for data range, position, title, axes, and data labels, similar to other line chart examples. ```python #Add a chart chart = sheet.Charts.Add() chart.ChartType = ExcelChartType.Line3D #Set region of chart data chart.DataRange = sheet.Range["A1:E5"] #Set position of chart chart.LeftColumn = 1 chart.TopRow = 6 chart.RightColumn = 11 chart.BottomRow = 29 #Set chart title chart.ChartTitle = "Sales market by country" chart.ChartTitleArea.IsBold = True chart.ChartTitleArea.Size = 12 chart.PrimaryCategoryAxis.Title = "Month" chart.PrimaryCategoryAxis.Font.IsBold = True chart.PrimaryCategoryAxis.TitleArea.IsBold = True chart.PrimaryValueAxis.Title = "Sales(in Dollars)" chart.PrimaryValueAxis.HasMajorGridLines = False chart.PrimaryValueAxis.TitleArea.TextRotationAngle = 90 chart.PrimaryValueAxis.MinValue = 1000 chart.PrimaryValueAxis.TitleArea.IsBold = True for cs in chart.Series: cs.Format.Options.IsVaryColor = True cs.DataPoints.DefaultDataPoint.DataLabels.HasValue = True chart.PlotArea.Fill.Visible = False chart.Legend.Position = LegendPositionType.Top ``` -------------------------------- ### Set First Page Number for Worksheet Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/Python Examples/xls_python.md This example demonstrates how to set the starting page number for an Excel worksheet to '2' using the PageSetup object. ```Python #Get the first worksheet sheet = workbook.Worksheets[0] #Set the first page number of the worksheet pages sheet.PageSetup.FirstPageNumber = 2 ``` -------------------------------- ### Hyperlink Properties Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/_autodocs/api-reference/hyperlink.md Explains the key properties of the Hyperlink class: Target, DisplayText, and SubAddress, with examples of how to get and set them. ```APIDOC ## Hyperlink Properties ### Description Provides access to and allows modification of hyperlink attributes such as the target URL, display text, and internal sub-address. ### Properties #### `Target` Gets or sets the URL or target address of the hyperlink. - **Type:** `str` #### `DisplayText` Gets or sets the text displayed for the hyperlink. - **Type:** `str` #### `SubAddress` Gets or sets the cell reference for internal links. - **Format:** Sheet name and cell reference (e.g., "Sheet2!A1") - **Type:** `str` ### Example Usage ```python # Assuming 'hyperlink' is an existing Hyperlink object hyperlink.Target = "https://www.google.com" # Change target current_target = hyperlink.Target hyperlink.DisplayText = "Visit Google" hyperperlink.SubAddress = "Sheet2!B5" # For internal links ``` ``` -------------------------------- ### Set up Data Validation Rules Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/_autodocs/README.md Initializes a workbook and worksheet to demonstrate setting up data validation rules. This snippet is a starting point for configuring validation constraints. ```python from spire.xls import Workbook, CellDataType, ValidationComparisonOperator workbook = Workbook() sheet = workbook.Worksheets[0] ``` -------------------------------- ### Create a new Workbook instance Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/_autodocs/api-reference/workbook.md Instantiate the Workbook class to create a new, empty Excel workbook. This is the starting point for most operations. ```python workbook = Workbook() ``` -------------------------------- ### Convert Excel to PDF Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/README.md This example shows how to load an existing Excel file and convert it into a PDF document. The SheetFitToPage setting is enabled for better page scaling in the PDF. ```Python from spire.xls import * from spire.common import * inputFile = "./Demos/Data/ToPDF.xlsx" outputFile = "ToPDF.pdf" #create a workbook workbook = Workbook() #load a excel document workbook.LoadFromFile(inputFile) workbook.ConverterSetting.SheetFitToPage = True #convert to PDF file workbook.SaveToFile(outputFile, FileFormat.PDF) workbook.Dispose() ``` -------------------------------- ### Workbook() Constructor Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/_autodocs/api-reference/workbook.md Initializes a new, empty Excel workbook with a single default worksheet. This is the starting point for most Excel document manipulations. ```APIDOC ## Workbook() ### Description Creates a new empty workbook with a default worksheet. ### Method Constructor ### Parameters (none) ### Request Example ```python from spire.xls import Workbook workbook = Workbook() workbook.Dispose() ``` ### Response - **Workbook instance**: A new `Workbook` instance with one empty worksheet. ``` -------------------------------- ### Get Paper Dimensions for Different Paper Sizes Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/Python Examples/xls_python.md This example demonstrates how to retrieve the width and height dimensions for various standard paper sizes (A2, A3, A4, Letter) within an Excel worksheet using PageSetup properties. ```Python # Create a workbook and get the first worksheet workbook = Workbook() sheet = workbook.Worksheets[0] # Get dimensions for different paper sizes sheet.PageSetup.PaperSize = PaperSizeType.A2Paper a2_dimensions = (sheet.PageSetup.PageWidth, sheet.PageSetup.PageHeight) sheet.PageSetup.PaperSize = PaperSizeType.PaperA3 a3_dimensions = (sheet.PageSetup.PageWidth, sheet.PageSetup.PageHeight) sheet.PageSetup.PaperSize = PaperSizeType.PaperA4 a4_dimensions = (sheet.PageSetup.PageWidth, sheet.PageSetup.PageHeight) sheet.PageSetup.PaperSize = PaperSizeType.PaperLetter letter_dimensions = (sheet.PageSetup.PageWidth, sheet.PageSetup.PageHeight) ``` -------------------------------- ### Set Page Header, Footer, and View Mode Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/Python Examples/xls_python.md Configure the page setup with custom headers and footers, and set the worksheet's view mode. ```python # Set left header with font name and size Worksheet.PageSetup.LeftHeader = "&\"Arial Unicode MS\"&14 Spire.XLS for .Python " # Set center footer Worksheet.PageSetup.CenterFooter = "Footer Text" # Set view mode Worksheet.ViewMode = ViewMode.Layout ``` -------------------------------- ### Create and Get Textbox by Name in Excel Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/Python Examples/xls_python.md Demonstrates how to create a textbox, set its name and text, and then retrieve it by its name from an Excel worksheet. ```python #Create a workbook workbook = Workbook() #Get the default first worksheet sheet = workbook.Worksheets[0] #Insert a TextBox sheet.Range["A2"].Text = "Name:" textBox = sheet.TextBoxes.AddTextBox(2, 2, 18, 65) #Set the name ttextBox.Name = "FirstTextBox" #Set string text for TextBox ttextBox.Text = "Spire.XLS for Python is a professional Excel Python API that can be used to create, read, write and convert Excel files in any type of python application. Spire.XLS for Python offers object model Excel API for speeding up Excel programming in python platform - create new Excel documents from template, edit existing Excel documents and convert Excel files." #Get the TextBox by the name FindTextBox = sheet.TextBoxes["FirstTextBox"] #Get the TextBox text text = FindTextBox.Text ``` -------------------------------- ### Create and Configure Hyperlinks Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/Python Examples/xls_python.md This example shows how to create various types of hyperlinks (website, email, forum) in an Excel worksheet and set their display text. It utilizes `HyperLinkType.Url` for all links. ```python # Set text for hyperlink labels sheet.Range["B9"].Text = "Home page" # Create hyperlink to website hylink1 = sheet.HyperLinks.Add(sheet.Range["B10"]) hylink1.Type = HyperLinkType.Url hylink1.Address = "http://www.e-iceblue.com" # Set text for email hyperlink sheet.Range["B11"].Text = "Support" # Create email hyperlink hylink2 = sheet.HyperLinks.Add(sheet.Range["B12"]) hylink2.Type = HyperLinkType.Url hylink2.Address = "mailto:support@e-iceblue.com" # Set text for forum hyperlink sheet.Range["B13"].Text = "Forum" # Create forum hyperlink hylink3 = sheet.HyperLinks.Add(sheet.Range["B14"]) hylink3.Type = HyperLinkType.Url hylink3.Address = "https://www.e-iceblue.com/forum/" ``` -------------------------------- ### Set and Get Cell Formula Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/_autodocs/api-reference/cell-range.md Shows how to set and retrieve the formula string for a cell using the Formula property. ```python # Set a formula sheet.Range["C1"].Formula = "=A1+B1" # Get the formula formula = sheet.Range["D1"].Formula print(f"Formula: {formula}") ``` -------------------------------- ### Custom Data Markers in Scatter Chart (Python) Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/Python Examples/xls_python.md This example shows how to create a scatter-markers chart and customize the appearance of data markers, including color, size, style, and transparency. ```python #Create a Scatter-Markers chart based on the sample data chart = sheet.Charts.Add(ExcelChartType.ScatterMarkers) chart.DataRange = sheet.Range["A1:B7"] chart.PlotArea.Visible = False chart.SeriesDataFromRange = False chart.TopRow = 5 chart.BottomRow = 22 chart.LeftColumn = 4 chart.RightColumn = 11 chart.ChartTitle = "Chart with Markers" chart.ChartTitleArea.IsBold = True chart.ChartTitleArea.Size = 10 #Format the markers in the chart by setting the background color, foreground color, type, size and transparency cs1 = chart.Series[0] cs1.DataFormat.MarkerBackgroundColor = Color.get_RoyalBlue() cs1.DataFormat.MarkerForegroundColor = Color.get_WhiteSmoke() cs1.DataFormat.MarkerSize = 7 cs1.DataFormat.MarkerStyle = ChartMarkerType.PlusSign cs1.DataFormat.MarkerTransparencyValue = 0.8 cs2 = chart.Series[1] cs2.DataFormat.MarkerBackgroundColor = Color.get_Pink() cs2.DataFormat.MarkerSize = 9 cs2.DataFormat.MarkerStyle = ChartMarkerType.Triangle cs2.DataFormat.MarkerTransparencyValue = 0.9 ``` -------------------------------- ### Set Font Size Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/_autodocs/api-reference/font.md Sets the font size in points. Examples show setting integer and floating-point values. It also demonstrates how to verify the font size applied to a cell. ```python font = workbook.CreateFont() font.Size = 12 # 12-point font font.Size = 14.5 font.Size = 8 # Verify size size = sheet.Range["A1"].Style.Font.Size ``` -------------------------------- ### Check if a Worksheet is a Dialog Sheet Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/Python Examples/xls_python.md Provides an example of how to get the first worksheet in a workbook. ```python # Get the first worksheet sheet = workbook.Worksheets[0] ``` -------------------------------- ### Create a Line Chart Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/Python Examples/xls_python.md This example shows how to create a basic line chart, set its data range, position, title, and customize axis labels and data point visibility. It also configures the legend position. ```python #Add a chart chart = sheet.Charts.Add() chart.ChartType = ExcelChartType.Line #Set region of chart data chart.DataRange = sheet.Range["A1:E5"] #Set position of chart chart.LeftColumn = 1 chart.TopRow = 6 chart.RightColumn = 11 chart.BottomRow = 29 #Set chart title chart.ChartTitle = "Sales market by country" chart.ChartTitleArea.IsBold = True chart.ChartTitleArea.Size = 12 chart.PrimaryCategoryAxis.Title = "Month" chart.PrimaryCategoryAxis.Font.IsBold = True chart.PrimaryCategoryAxis.TitleArea.IsBold = True chart.PrimaryValueAxis.Title = "Sales(in Dollars)" chart.PrimaryValueAxis.HasMajorGridLines = False chart.PrimaryValueAxis.TitleArea.TextRotationAngle = 90 chart.PrimaryValueAxis.MinValue = 1000 chart.PrimaryValueAxis.TitleArea.IsBold = True for cs in chart.Series: cs.Format.Options.IsVaryColor = True cs.DataPoints.DefaultDataPoint.DataLabels.HasValue = True chart.PlotArea.Fill.Visible = False chart.Legend.Position = LegendPositionType.Top ``` -------------------------------- ### Create Pie Chart Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/_autodocs/INDEX.md Shows how to create a pie chart. Chart configuration includes type, data range, and series. ```python from spire.xls import Workbook, ChartType # Create a workbook bk = Workbook() ws = bk.worksheets[0] # Add some data ws.cell_value("A1", "Category") ws.cell_value("B1", "Value") ws.cell_value("A2", "A") ws.cell_value("B2", 10) ws.cell_value("A3", "B") ws.cell_value("B3", 20) # Add a pie chart chart = ws.charts.add(ChartType.Pie) chart.data_range = "A1:B3" chart.series[0].name_range = "B1" ``` -------------------------------- ### Create a Product Gallery with Pictures Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/_autodocs/api-reference/picture.md Generates an Excel file displaying a product gallery with labels and corresponding images arranged in a grid layout. Requires image files to be present. ```python from spire.xls import Workbook workbook = Workbook() sheet = workbook.Worksheets[0] # Add title sheet.Range["A1"].Text = "Product Gallery" sheet.Range["A1"].Style.Font.IsBold = True sheet.Range["A1"].Style.Font.Size = 14 # Set up layout: 2 columns, 3 rows image_files = [ "./product1.jpg", "./product2.jpg", "./product3.jpg", "./product4.jpg", "./product5.jpg", "./product6.jpg", ] row = 3 col = 1 for idx, image_file in enumerate(image_files): # Add label sheet.Range[row, col].Text = f"Product {idx + 1}" # Add picture below label picture = sheet.Pictures.Add(row + 1, col, image_file) picture.Width = 150 picture.Height = 150 # Move to next position col += 1 if col > 2: # 2 columns col = 1 row += 3 # Move down 3 rows (1 for label, 2 for picture) workbook.SaveToFile("gallery.xlsx") workbook.Dispose() ``` -------------------------------- ### Get Named Range from Cell Range in Excel Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/Python Examples/xls_python.md This example demonstrates how to retrieve the named range associated with a specific cell range in an Excel sheet. ```python # Create a workbook. workbook = Workbook() # Get the first sheet sheet = workbook.Worksheets[0] # Get some cellRanges cellRange = sheet.Range["A2:D2"] # Get the named range object result = cellRange.GetNamedRange() ``` -------------------------------- ### Create Simple Excel File with 'Hello World' Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/Python Examples/xls_python.md Creates a basic Excel file with a single worksheet named 'MySheet' and places the text 'Hello World' in cell A1, automatically adjusting column width. ```python workbook = Workbook() sheet = workbook.Worksheets.Add("MySheet") sheet.Range["A1"].Text = "Hello World" sheet.Range["A1"].AutoFitColumns() ``` -------------------------------- ### Get Chart Data Point Values from Excel Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/Python Examples/xls_python.md This example demonstrates how to iterate through the values of a chart's series and extract the range address and value for each data point. ```python # Get the first sheet sheet = workbook.Worksheets[0] # Get the chart chart = sheet.Charts[0] # Get the first series of the chart cs = chart.Series[0] for cr in cs.Values: # Get the range address range_address = cr.RangeAddress # Get the data point value value = cr.Value ``` -------------------------------- ### Create a Pie Chart Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/Python Examples/xls_python.md This example shows how to create a pie chart, specifying the data range for values and category labels separately. It also configures the chart title and data label visibility. ```python #Add a chart chart = sheet.Charts.Add(ExcelChartType.Pie) #Set region of chart data chart.DataRange = sheet.Range["B2:B5"] chart.SeriesDataFromRange = False #Set position of chart chart.LeftColumn = 1 chart.TopRow = 6 chart.RightColumn = 9 chart.BottomRow = 25 #Chart title chart.ChartTitle = "Sales by year" chart.ChartTitleArea.IsBold = True chart.ChartTitleArea.Size = 12 cs = chart.Series[0] cs.CategoryLabels = sheet.Range["A2:A5"] cs.Values = sheet.Range["B2:B5"] cs.DataPoints.DefaultDataPoint.DataLabels.HasValue = True chart.PlotArea.Fill.Visible = False ``` -------------------------------- ### Get Data Validation Settings from Excel Cell in Python Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/Python Examples/xls_python.md Retrieves and displays the data validation settings for a specific cell in an Excel worksheet. This example focuses on a cell with Decimal validation. ```Python #Get first worksheet of the workbook worksheet = workbook.Worksheets[0] #Cell B4 has the Decimal Validation cell = worksheet.Range["B4"] #Get the validation of this cell validation = cell.DataValidation #Get the settings allowType = str(validation.AllowType) data = str(validation.CompareOperator) minimum = str(validation.Formula1) maximum = str(validation.Formula2) ignoreBlank = str(validation.IgnoreBlank) ``` -------------------------------- ### Set Page Margins for Excel Worksheet Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/Python Examples/xls_python.md This example demonstrates how to set the bottom, left, right, and top page margins for an Excel worksheet using the PageSetup object. ```Python #Get the PageSetup object of the worksheet. pageSetup = sheet.PageSetup #Set bottom,left,right and top page margins. pageSetup.BottomMargin = 2 pageSetup.LeftMargin = 1 pageSetup.RightMargin = 1 pageSetup.TopMargin = 3 ``` -------------------------------- ### Get Specific Named Range by Index or Name Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/Python Examples/xls_python.md This example shows how to access a specific named range either by its numerical index or by its string name. It retrieves the name of the named range for both methods. ```python #Get specific named range by index name1 = workbook.NameRanges[1].Name #Get specific named range by name name2 = workbook.NameRanges["NameRange3"].Name ``` -------------------------------- ### Get Displayed Cell Text in Python Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/Python Examples/xls_python.md Retrieves the text of a cell as it is displayed, considering its number format. This example sets a number value and a specific format to demonstrate how DisplayedText reflects the formatting. ```python #Get a cell from worksheet cell = worksheet.Range["B8"] #Set value and format for the cell cell.NumberValue = 0.012345 style = cell.Style style.NumberFormat = "0.00" #Get the displayed text of the cell displayedText = cell.DisplayedText ``` -------------------------------- ### Create and save a new Workbook Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/_autodocs/api-reference/workbook.md Demonstrates creating a new workbook, adding content to a worksheet, saving it to a file, and disposing of the workbook resources. ```python from spire.xls import Workbook # Create a new workbook workbook = Workbook() # Access the default worksheet sheet = workbook.Worksheets[0] sheet.Range["A1"].Text = "Hello World" workbook.SaveToFile("output.xlsx") workbook.Dispose() ``` -------------------------------- ### Creating Email Links Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/_autodocs/api-reference/hyperlink.md Illustrates how to create hyperlinks that initiate an email, with options to pre-fill the recipient, subject, and body. ```APIDOC ## Creating Email Links ### Description Generates hyperlinks that, when clicked, open the user's default email client. Supports pre-setting the recipient, subject, and email body. ### Method `sheet.Hyperlinks.Add(cell_range, mailto_url)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python # Create mailto link email_link = sheet.Hyperlinks.Add(sheet.Range["B1"], "mailto:contact@example.com") sheet.Range["B1"].Text = "Email Us" # With subject email_link = sheet.Hyperlinks.Add(sheet.Range["B2"], "mailto:support@example.com?subject=Help%20Request") sheet.Range["B2"].Text = "Request Support" # With CC and body email_link = sheet.Hyperlinks.Add( sheet.Range["B3"], "mailto:sales@example.com?cc=manager@example.com&subject=Quote%20Request" ) sheet.Range["B3"].Text = "Request Quote" ``` ``` -------------------------------- ### Create a Line Chart with Circle Markers Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/Python Examples/xls_python.md This example creates a line chart and specifically sets the marker style to 'Circle' for each data point. It also configures data labels and legend position. ```python #Add a chart chart = sheet.Charts.Add() chart.ChartType = ExcelChartType.Line #Set region of chart data chart.DataRange = sheet.Range["A1:E5"] #Set position of chart chart.LeftColumn = 1 chart.TopRow = 6 chart.RightColumn = 11 chart.BottomRow = 29 #Set chart title chart.ChartTitle = "Sales market by country" chart.ChartTitleArea.IsBold = True chart.ChartTitleArea.Size = 12 chart.PrimaryCategoryAxis.Title = "Month" chart.PrimaryCategoryAxis.Font.IsBold = True chart.PrimaryCategoryAxis.TitleArea.IsBold = True chart.PrimaryValueAxis.Title = "Sales(in Dollars)" chart.PrimaryValueAxis.HasMajorGridLines = False chart.PrimaryValueAxis.TitleArea.TextRotationAngle = 90 chart.PrimaryValueAxis.MinValue = 1000 chart.PrimaryValueAxis.TitleArea.IsBold = True for cs1 in chart.Series: cs = ChartSerie(cs1) cs.Format.Options.IsVaryColor = True cs.DataPoints.DefaultDataPoint.DataLabels.HasValue = True cs.DataFormat.MarkerStyle = ChartMarkerType.Circle chart.PlotArea.Fill.Visible = False chart.Legend.Position = LegendPositionType.Top ``` -------------------------------- ### ExcelColors Usage Example Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/_autodocs/types.md Demonstrates how to apply a predefined color to a cell's style. This example sets the background color of cell A1 to 25% gray. ```python sheet.Range["A1"].Style.KnownColor = ExcelColors.Gray25Percent ``` -------------------------------- ### Style Hyperlinks Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/_autodocs/api-reference/hyperlink.md Demonstrates how to create and format a hyperlink with custom display text. ```python from spire.xls import Workbook from spire.common import Color workbook = Workbook() sheet = workbook.Worksheets[0] # Create and format link hyperlink = sheet.Hyperlinks.Add(sheet.Range["A1"], "https://www.example.com") sheet.Range["A1"].Text = "Click Here" ``` -------------------------------- ### Delete Multiple Rows and Columns Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/Python Examples/xls_python.md Deletes a specified number of rows starting from a given row index, or a specified number of columns starting from a given column index. Indices are 1-based. ```python #Delete 4 rows from the fifth row sheet.DeleteRow(5, 4) #Delete 2 columns from the second column sheet.DeleteColumn(2, 2) ``` -------------------------------- ### Get Address of a Named Range Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/Python Examples/xls_python.md This code retrieves the address of a specific named range within an Excel workbook. It accesses the named range by its index and then gets the RangeAddress property of its referred range. ```python # Get specific named range by index NamedRange = workbook.NameRanges[0] # Get the address of the named range address = NamedRange.RefersToRange.RangeAddress ``` -------------------------------- ### Create and Format Excel Tables Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/_autodocs/QUICK_REFERENCE.md Demonstrates creating a structured table from a range of cells, applying a built-in style, and configuring features like total rows and calculations. ```python table = sheet.ListObjects.Create("Table1", sheet.Range["A1:D10"]) table.BuiltInTableStyle = TableBuiltInStyles.TableStyleLight9 table.DisplayTotalRow = True table.Columns[3].TotalsCalculation = ExcelTotalsCalculation.Sum ``` -------------------------------- ### Create a TreeMap Chart Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/Python Examples/xls_python.md This example shows how to create a TreeMap chart, setting its type, data range, position, title, and label options. It also configures data label formatting. ```python #add a new chart officeChart = sheet.Charts.Add() #set chart type as TreeMap officeChart.ChartType = ExcelChartType.TreeMap #set data range in the worksheet officeChart.DataRange = sheet["A2:C11"] officeChart.TopRow = 1 officeChart.BottomRow = 19 officeChart.LeftColumn = 4 officeChart.RightColumn = 14 #Set the chart title officeChart.ChartTitle = "Area by countries" #set the Treemap label option officeChart.Series[0].DataFormat.TreeMapLabelOption = ExcelTreeMapLabelOption.Banner #format data labels officeChart.Series[0].DataPoints.DefaultDataPoint.DataLabels.Size = 8 ``` -------------------------------- ### Delete a Cell Comment Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/_autodocs/api-reference/comment.md Provides an example of how to remove a comment from a specific cell. ```python comment = sheet.Range["A1"].Comment if comment: comment.Delete() ``` -------------------------------- ### ChartType Property Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/_autodocs/api-reference/chart.md Explains how to get or set the type of chart using the `ChartType` property. ```APIDOC ### `ChartType` Gets or sets the type of chart. **Type:** `ChartType` **Values:** - `ChartType.ColumnClustered` — Clustered column chart - `ChartType.ColumnStacked` — Stacked column chart - `ChartType.ColumnPercentStacked` — Percent stacked column - `ChartType.BarClustered` — Clustered bar chart - `ChartType.BarStacked` — Stacked bar chart - `ChartType.BarPercentStacked` — Percent stacked bar - `ChartType.LineStacked` — Stacked line chart - `ChartType.LineMarkers` — Line with markers - `ChartType.LineMarkersStacked` — Stacked line with markers - `ChartType.PieExploded` — Exploded pie chart - `ChartType.Pie3D` — 3D pie chart - `ChartType.AreaStacked` — Stacked area chart - `ChartType.DoughnutExploded` — Exploded doughnut - `ChartType.Radar` — Radar chart - `ChartType.RadarFilled` — Filled radar - `ChartType.Surface3D` — 3D surface chart - `ChartType.ScatterSmooth` — Smooth scatter - `ChartType.ScatterMarkers` — Scatter with markers - `ChartType.BubbleMarkers` — Bubble chart **Example:** ```python chart = sheet.Charts.Add() chart.ChartType = ChartType.ColumnClustered ``` ``` -------------------------------- ### Create, Load, Save, and Dispose Workbook Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/_autodocs/QUICK_REFERENCE.md Demonstrates the basic lifecycle of a workbook: creating a new one, loading from a file, setting passwords for encrypted files, saving in various formats (Excel, PDF, CSV), and proper disposal. ```python # Create new workbook workbook = Workbook() ``` ```python # Load existing file workbook = Workbook() workbook.LoadFromFile("file.xlsx") ``` ```python # Set password for encrypted files workbook.OpenPassword = "password" workbook.LoadFromFile("encrypted.xlsx") ``` ```python # Save file workbook.SaveToFile("output.xlsx", ExcelVersion.Version2010) ``` ```python # Save as other formats workbook.SaveToFile("output.pdf", FileFormat.PDF) workbook.SaveToFile("output.csv", FileFormat.CSV) ``` ```python # Cleanup workbook.Dispose() ``` -------------------------------- ### Set Comment Visibility (On Hover) Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/_autodocs/api-reference/comment.md Example of setting a comment to be visible only when the mouse hovers over the cell. ```python # Visible only on hover comment.Visible = False ``` -------------------------------- ### Create and Apply Cell Styles in Excel Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/Python Examples/xls_python.md Demonstrates how to create a workbook, add a worksheet, access cells, create a custom style with various formatting options (alignment, font, borders), and apply it to cells. ```python #Create a workbook and worksheet workbook = Workbook() sheet = workbook.Worksheets.Add("new sheet") #Access the "B1" cell from the worksheet cell = sheet.Range["B1"] cell.Text = "Hello Spire!" #Create a new style style = workbook.Styles.Add("newStyle") #Configure style properties style.VerticalAlignment = VerticalAlignType.Center style.HorizontalAlignment = HorizontalAlignType.Center style.Font.Color = Color.get_Blue() style.ShrinkToFit = True style.Borders[BordersLineType.EdgeBottom].Color = Color.get_GreenYellow() style.Borders[BordersLineType.EdgeBottom].LineStyle = LineStyleType.Medium #Apply the style to cells cell.Style = style sheet.Range["B4"].Style = style sheet.Range["B4"].Text = "Test" sheet.Range["C3"].CellStyleName = style.Name sheet.Range["C3"].Text = "Welcome to use Spire.XLS" sheet.Range["D4"].Style = style ``` -------------------------------- ### Set Comment Visibility (Always Visible) Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/_autodocs/api-reference/comment.md Example of setting a comment to be always visible on the worksheet. ```python # Always visible comment.Visible = True ``` -------------------------------- ### Get Cell Comment Text Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/_autodocs/api-reference/cell-range.md Retrieves the text of a cell's comment if one exists. ```python comment = sheet.Range["A1"].Comment if comment: print(f"Comment: {comment.Text}") ``` -------------------------------- ### Control Excel Comment Visibility Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/Python Examples/xls_python.md Get the first worksheet and control the visibility of specific comments by their index. ```python # Get the first worksheet sheet = workbook.Worksheets[0] # Hide the second comment sheet.Comments[1].IsVisible = False # Show the third comment sheet.Comments[2].IsVisible = True ``` -------------------------------- ### Create Line Chart Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/_autodocs/INDEX.md Illustrates creating a line chart. The library supports various chart types for data visualization. ```python from spire.xls import Workbook, ChartType # Create a workbook bk = Workbook() ws = bk.worksheets[0] # Add some data ws.cell_value("A1", "X-Axis") ws.cell_value("B1", "Y-Axis") ws.cell_value("A2", 1) ws.cell_value("B2", 5) ws.cell_value("A3", 2) ws.cell_value("B3", 8) # Add a line chart chart = ws.charts.add(ChartType.Line) chart.data_range = "A1:B3" chart.series[0].name_range = "B1" ``` -------------------------------- ### Edit Excel Comment Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/Python Examples/xls_python.md Get the first worksheet and comment, then edit the comment's text content. ```python #Get the first worksheet. sheet = workbook.Worksheets[0] #Get the first comment. comment = sheet.Comments[0] #Edit the comment. comment.Text = "This comment has been edited by Spire.XLS." ``` -------------------------------- ### Set Reference Range for a Picture in Excel Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/Python Examples/xls_python.md Get the first picture in a worksheet and set its reference range. ```python #Get the first picture in worksheet picture = sheet.Pictures[0] #Set the reference range of the picture to A1:B3 picture.RefRange = "A1:B3" ``` -------------------------------- ### Open Various Excel File Formats Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/Python Examples/xls_python.md This example demonstrates opening Excel files in different formats using Spire.XLS. It covers loading by file path, file stream, older .xls files, XML files, and CSV files. Adjust the file paths and parameters as needed for your specific files. ```python # 1. Load file by file path workbook1 = Workbook() workbook1.LoadFromFile("path_to_excel_file.xlsx") # 2. Load file by file stream stream = Stream("path_to_excel_file.xlsx") workbook2 = Workbook() workbook2.LoadFromStream(stream) stream.Dispose() # 3. Open Microsoft Excel 97 - 2003 file wbExcel97 = Workbook() wbExcel97.LoadFromFile("path_to_excel97_file.xls", ExcelVersion.Version97to2003) # 4. Open xml file wbXML = Workbook() wbXML.LoadFromXml("path_to_xml_file.xml") # 5. Open csv file wbCSV = Workbook() wbCSV.LoadFromFile("path_to_csv_file.csv", ",", 1, 1) ``` -------------------------------- ### Adjust Image Position in Excel Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/Python Examples/xls_python.md Get the first sheet and picture, then adjust its left and top offsets. ```python #Get the first sheet sheet = workbook.Worksheets[0] pic = sheet.Pictures[0] pic.LeftColumnOffset = 300 pic.TopRowOffset = 300 ``` -------------------------------- ### Batch Create Excel Files with Sample Data Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/Python Examples/xls_python.md Generates multiple Excel files (up to 50) in a batch process. Each file contains a workbook with five sheets, populated with sample data. ```python for n in range(0, 50): workbook = Workbook() workbook.CreateEmptySheets(5) for i in range(0, 5): sheet = workbook.Worksheets[i] sheet.Name = "Sheet" + str(i) for row in range(1, 15): for col in range(1, 5): sheet.Range[row,col].Text = "row" + str(row) + " col" + str(col) workbook.SaveToFile("Workbook" + str(n) + ".xlsx", ExcelVersion.Version2010) workbook.Dispose() ``` -------------------------------- ### Optimize Image Dimensions Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/_autodocs/api-reference/picture.md Illustrates setting the width and height of a picture. It's recommended to use appropriately sized images to manage file size effectively, preferring web-optimized versions over high-resolution originals. ```python # Use appropriately sized images to keep file size manageable # Instead of high-resolution originals, use web-optimized versions picture.Width = 200 # Width in pixels picture.Height = 150 # Height in pixels ``` -------------------------------- ### Get Formula Calculated Value Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/_autodocs/api-reference/cell-range.md Retrieves the calculated result of a formula in a cell using the FormulaValue property. ```python sheet.Range["A1"].NumberValue = 10 sheet.Range["B1"].NumberValue = 20 sheet.Range["C1"].Formula = "=A1+B1" result = sheet.Range["C1"].FormulaValue # Returns 30 ``` -------------------------------- ### Create Internal Workbook Navigation Links Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/_autodocs/api-reference/hyperlink.md Demonstrates setting up navigation between different sheets within the same workbook using SubAddress. ```python from spire.xls import Workbook workbook = Workbook() # Create multiple sheets sheet1 = workbook.Worksheets[0] sheet1.Name = "Index" sheet2 = workbook.Worksheets.Add("Details") sheet3 = workbook.Worksheets.Add("Appendix") # Create navigation links in Index sheet nav_link1 = sheet1.Hyperlinks.Add(sheet1.Range["A1"], "") nav_link1.SubAddress = "Details!A1" sheet1.Range["A1"].Text = "Go to Details" nav_link2 = sheet1.Hyperlinks.Add(sheet1.Range["A2"], "") nav_link2.SubAddress = "Appendix!A1" sheet1.Range["A2"].Text = "Go to Appendix" # In Details sheet, link back to Index back_link = sheet2.Hyperlinks.Add(sheet2.Range["A1"], "") back_link.SubAddress = "Index!A1" sheet2.Range["A1"].Text = "Back to Index" # Add content to sheets sheet2.Range["A3"].Text = "Details content here" sheet3.Range["A3"].Text = "Appendix content here" workbook.SaveToFile("navigation_workbook.xlsx") workbook.Dispose() ``` -------------------------------- ### ChartTitle Properties Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/_autodocs/api-reference/chart.md Provides examples for configuring chart title properties such as text, font name, size, and color. ```APIDOC ## ChartTitle Properties ```python chart.Title.Text = "My Chart Title" chart.Title.Format.Font.FontName = "Arial" chart.Title.Format.Font.Size = 14 chart.Title.Format.Font.IsBold = True chart.Title.Format.Font.Color = Color.get_Black() ``` ``` -------------------------------- ### DeleteRow Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/_autodocs/api-reference/worksheet.md Deletes one or more rows from the worksheet, starting at a specified row index. You can control the number of rows to be removed. ```APIDOC ## `DeleteRow(rowIndex: int, rowCount?: int)` Deletes one or more rows from the worksheet. | Parameter | Type | Required | Default | Description | |-----------|------|----------|---------|-------------| | rowIndex | int | Yes | — | 1-based row index to delete | | rowCount | int | No | 1 | Number of rows to delete | **Returns:** None **Example:** ```python sheet.DeleteRow(5) # Delete row 5 sheet.DeleteRow(10, 3) # Delete rows 10-12 ``` ``` -------------------------------- ### Retrieve Hyperlink from Picture in Excel Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/Python Examples/xls_python.md This snippet shows how to get the hyperlink attached to a picture within an Excel worksheet. ```python # Create a workbook instance workbook = Workbook() # Get the first worksheet in the workbook sheet = workbook.Worksheets.get_Item(0) # Get the first picture found in the worksheet picture = sheet.Pictures.get_Item(0) # Retrieve the hyperlink attached to the picture link = picture.GetHyperLink() # Extract the address (URL or file path) of the hyperlink address = link.Address ``` -------------------------------- ### Creating a Chart Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/_autodocs/api-reference/chart.md Demonstrates how to create a new chart instance within a worksheet. ```APIDOC ## Constructor / Creation ### Creating a Chart ```python # Create a new chart in a worksheet chart = sheet.Charts.Add() ``` ``` -------------------------------- ### Set Header and Footer with Image for First Page Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/Python Examples/xls_python.md This example configures custom headers and footers, including images, specifically for the first page of an Excel document. It also sets the view mode to Layout for visual confirmation. ```python # Set the value to show the headers/footers for first page are different from the other pages. sheet.PageSetup.DifferentFirst = 1 # Set image and text for first page header and footer sheet.PageSetup.SetFirstLeftHeaderImage(imageStream) sheet.PageSetup.SetFirstLeftFooterImage(imageStream) sheet.PageSetup.LeftHeader = "Demo of Spire.XLS" sheet.PageSetup.LeftFooter = "Footer by Spire.XLS" sheet.ViewMode = ViewMode.Layout ``` -------------------------------- ### Access Worksheet Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/_autodocs/INDEX.md Shows how to get a specific worksheet from the workbook by its index. Worksheets can be managed using the Worksheet class. ```python from spire.xls import Workbook # Load workbook bk = Workbook() bk.load_from_file("sample.xlsx") # Get the first worksheet ws = bk.worksheets[0] ``` -------------------------------- ### Create Multiple External Web Links Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/_autodocs/api-reference/hyperlink.md Demonstrates creating hyperlinks to different types of web addresses (secured, HTTP) and assigning display text. ```python from spire.xls import Workbook workbook = Workbook() sheet = workbook.Worksheets[0] # Web link link1 = sheet.Hyperlinks.Add(sheet.Range["A1"], "https://www.example.com") sheet.Range["A1"].Text = "Company Website" # Secured web link link2 = sheet.Hyperlinks.Add(sheet.Range["A2"], "https://secure.example.com") sheet.Range["A2"].Text = "Login Page" # HTTP link link3 = sheet.Hyperlinks.Add(sheet.Range["A3"], "http://www.oldsite.com") sheet.Range["A3"].Text = "Legacy Site" workbook.SaveToFile("web_links.xlsx") workbook.Dispose() ``` -------------------------------- ### Create New Workbook Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/_autodocs/INDEX.md Demonstrates the basic pattern for creating a new Excel workbook using the Workbook class. ```python from spire.xls import Workbook # Create a workbook bk = Workbook() ``` -------------------------------- ### Set and Get Cell Text Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/_autodocs/api-reference/cell-range.md Demonstrates how to set and retrieve the text content of a cell using the Text property. ```python # Set text sheet.Range["A1"].Text = "Hello World" # Get text text = sheet.Range["B1"].Text print(f"Cell content: {text}") ``` -------------------------------- ### Apply RGB Colors to Fonts Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/_autodocs/api-reference/font.md Demonstrates creating custom colors using RGB values and applying one to a font. ```python from spire.common import Color # Create RGB color red = Color.FromArgb(255, 0, 0) # Pure red blue = Color.FromArgb(0, 0, 255) # Pure blue custom = Color.FromArgb(128, 64, 32) # Custom color font = workbook.CreateFont() font.Color = custom ``` -------------------------------- ### Move Chart Sheets in Excel Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/Python Examples/xls_python.md This example shows how to reposition chart sheets within an Excel workbook using Spire.XLS. ```python # Create a workbook workbook = Workbook() # Move chart worksheets workbook.Chartsheets[0].MoveSheet(2) workbook.Chartsheets[0].MoveChartsheet(0) ``` -------------------------------- ### DeleteColumn Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/_autodocs/api-reference/worksheet.md Deletes one or more columns from the worksheet, starting at a specified column index. This is useful for removing unnecessary data columns. ```APIDOC ## `DeleteColumn(columnIndex: int, columnCount?: int)` Deletes one or more columns from the worksheet. | Parameter | Type | Required | Default | Description | |-----------|------|----------|---------|-------------| | columnIndex | int | Yes | — | 1-based column index to delete | | columnCount | int | No | 1 | Number of columns to delete | **Returns:** None **Example:** ```python sheet.DeleteColumn(3) # Delete column C sheet.DeleteColumn(5, 2) # Delete columns E-F ``` ``` -------------------------------- ### Create a New Workbook Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/_autodocs/README.md Creates a new Excel workbook, adds basic data to cells, and saves it to a file. Remember to dispose of the workbook when done. ```python from spire.xls import Workbook # Create a new workbook workbook = Workbook() # Access the default worksheet sheet = workbook.Worksheets[0] # Add data to cells sheet.Range["A1"].Text = "Hello World" sheet.Range["B1"].NumberValue = 42 # Save the file workbook.SaveToFile("output.xlsx") workbook.Dispose() ``` -------------------------------- ### Get Excel File Version Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/Python Examples/xls_python.md This snippet shows how to retrieve the version information of an Excel file using the Workbook object. ```Python # Create a workbook workbook = Workbook() # Get the version version = workbook.Version ``` -------------------------------- ### Set and Get Cell Boolean Value Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/_autodocs/api-reference/cell-range.md Illustrates setting and retrieving a boolean value for a cell using the BooleanValue property. ```python sheet.Range["A1"].BooleanValue = True is_true = sheet.Range["B1"].BooleanValue ``` -------------------------------- ### Create and Style a Table Source: https://github.com/eiceblue/spire.xls-for-python/blob/main/_autodocs/api-reference/worksheet.md Demonstrates creating a table object within a specified range and applying a built-in style. Requires `TableBuiltInStyles` enum. ```python # Create a table table = sheet.ListObjects.Create("Table1", sheet.Range["A1:D10"]) table.BuiltInTableStyle = TableBuiltInStyles.TableStyleLight9 ```