HtmlTableLoadOptionCollection.Add

Add(HtmlTableLoadOption)

Adds one HtmlTableLoadOption into this collection.

public int Add(HtmlTableLoadOption item)
ParameterTypeDescription
itemHtmlTableLoadOptionone HtmlTableLoadOption

Return Value

the index of the added item

Examples

using System;
using Aspose.Cells;

namespace AsposeCellsExamples
{
    public class HtmlTableLoadOptionCollectionMethodAddWithHtmlTableLoadOptionDemo
    {
        public static void Run()
        {
            // Create HTML load options
            HtmlLoadOptions loadOptions = new HtmlLoadOptions();
            
            // Add table load options
            HtmlTableLoadOption tableLoadOption1 = new HtmlTableLoadOption();
            tableLoadOption1.Id = "table1";
            loadOptions.TableLoadOptions.Add(tableLoadOption1);

            HtmlTableLoadOption tableLoadOption2 = new HtmlTableLoadOption();
            tableLoadOption2.Id = "table2";
            tableLoadOption2.TargetSheetIndex = 1;
            loadOptions.TableLoadOptions.Add(tableLoadOption2);

            // Load workbook with options
            Workbook workbook = new Workbook("input.html", loadOptions);
            
            // Save the output
            workbook.Save("output.xlsx");
        }
    }
}

See Also


Add(int)

Add a HtmlTableLoadOption to the list.

public int Add(int tableIndex)
ParameterTypeDescription
tableIndexInt32Table index

Examples

using System;
using Aspose.Cells;

namespace AsposeCellsExamples
{
    public class HtmlTableLoadOptionCollectionMethodAddWithInt32Demo
    {
        public static void Run()
        {
            // Create HtmlLoadOptions
            HtmlLoadOptions loadOptions = new HtmlLoadOptions();

            // Access the HtmlTableLoadOptionCollection instance
            HtmlTableLoadOptionCollection tableLoadOptions = loadOptions.TableLoadOptions;

            // Add a new HtmlTableLoadOption by table index
            int index = tableLoadOptions.Add(0);

            // Access the added HtmlTableLoadOption
            HtmlTableLoadOption option = tableLoadOptions[index];
            option.TableToListObject = true;

            // Create a workbook and load HTML with options
            Workbook workbook = new Workbook("input.html", loadOptions);

            // Save the workbook
            workbook.Save("output.xlsx");
        }
    }
}

See Also


Add(string)

Add a HtmlTableLoadOption to the list.

public int Add(string tableId)
ParameterTypeDescription
tableIdStringTable ID

Examples

using System;
using Aspose.Cells;

namespace AsposeCellsExamples
{
    public class HtmlTableLoadOptionCollectionMethodAddWithStringDemo
    {
        public static void Run()
        {
            // Create HtmlLoadOptions
            HtmlLoadOptions loadOptions = new HtmlLoadOptions();

            // Access the HtmlTableLoadOptionCollection instance
            HtmlTableLoadOptionCollection tableLoadOptions = loadOptions.TableLoadOptions;

            // Add a new HtmlTableLoadOption by table id
            int index = tableLoadOptions.Add("mainTable");

            // Access the added HtmlTableLoadOption
            HtmlTableLoadOption option = tableLoadOptions[index];
            option.TableToListObject = true;
            option.TargetSheetIndex = 0;

            // Create workbook and load HTML with options
            Workbook workbook = new Workbook("input.html", loadOptions);

            // Save the workbook
            workbook.Save("output.xlsx");
        }
    }
}

See Also


Add(int, int)

Add a HtmlTableLoadOption to the list.

public int Add(int tableIndex, int targetSheetIndex)
ParameterTypeDescription
tableIndexInt32Table index
targetSheetIndexInt32The target index of worksheet in Excel

Examples

using System;
using Aspose.Cells;

namespace AsposeCellsExamples
{
    public class HtmlTableLoadOptionCollectionMethodAddWithInt32Int32Demo
    {
        public static void Run()
        {
            // Create HTML load options
            HtmlLoadOptions loadOptions = new HtmlLoadOptions();
            
            // Add tables by index with target sheet index
            loadOptions.TableLoadOptions.Add(0, 2); // Table index 0 to sheet index 2
            loadOptions.TableLoadOptions.Add(1, 0); // Table index 1 to sheet index 0
            loadOptions.TableLoadOptions.Add(2, 1); // Table index 2 to sheet index 1

            // Load HTML file with the specified options
            Workbook workbook = new Workbook("input.html", loadOptions);
            
            // Save the workbook
            workbook.Save("output.xlsx");
        }
    }
}

See Also


Add(string, int)

Add a HtmlTableLoadOption to the list.

public int Add(string tableId, int targetSheetIndex)
ParameterTypeDescription
tableIdStringTable ID
targetSheetIndexInt32The target index of worksheet in Excel

Examples

using System;
using Aspose.Cells;

namespace AsposeCellsExamples
{
    public class HtmlTableLoadOptionCollectionMethodAddWithStringInt32Demo
    {
        public static void Run()
        {
            // Create HtmlLoadOptions
            HtmlLoadOptions loadOptions = new HtmlLoadOptions();

            // Access the HtmlTableLoadOptionCollection instance
            HtmlTableLoadOptionCollection tableLoadOptions = loadOptions.TableLoadOptions;

            // Add a new HtmlTableLoadOption by table id and target sheet index
            int index = tableLoadOptions.Add("tableId", 1);

            // Create a workbook and load HTML with options
            Workbook workbook = new Workbook("input.html", loadOptions);

            // Save the workbook
            workbook.Save("output.xlsx");
        }
    }
}

See Also


Add(int, int, int)

Add a HtmlTableLoadOption to the list.

public int Add(int tableIndex, int targetSheetIndex, int originalSheetIndex)
ParameterTypeDescription
tableIndexInt32Table index
targetSheetIndexInt32The target index of worksheet in Excel
originalSheetIndexInt32The original index of worksheet in the html

Examples

using System;
using Aspose.Cells;

namespace AsposeCellsExamples
{
    public class HtmlTableLoadOptionCollectionMethodAddWithInt32Int32Int32Demo
    {
        public static void Run()
        {
            // Create HtmlLoadOptions
            HtmlLoadOptions loadOptions = new HtmlLoadOptions();
            
            // Access the HtmlTableLoadOptionCollection
            HtmlTableLoadOptionCollection tableLoadOptions = loadOptions.TableLoadOptions;

            // Add a table with index 1, target sheet index 1, and original sheet index 0
            int addedIndex = tableLoadOptions.Add(1, 1, 0);

            // Create a workbook and load HTML with options
            Workbook workbook = new Workbook("input.html", loadOptions);

            // Save the result
            workbook.Save("output.xlsx");
        }
    }
}

See Also


Add(string, int, int)

Add a HtmlTableLoadOption to the list.

public int Add(string tableId, int targetSheetIndex, int originalSheetIndex)
ParameterTypeDescription
tableIdStringTable ID
targetSheetIndexInt32The target index of worksheet in Excel
originalSheetIndexInt32The original index of worksheet in the html

Examples

using System;
using Aspose.Cells;

namespace AsposeCellsExamples
{
    public class HtmlTableLoadOptionCollectionMethodAddWithStringInt32Int32Demo
    {
        public static void Run()
        {
            Workbook workbook = new Workbook();
            HtmlLoadOptions loadOptions = new HtmlLoadOptions();
            HtmlTableLoadOptionCollection tableLoadOptions = loadOptions.TableLoadOptions;

            // Demonstrate Add method with (String, Int32, Int32) parameters
            int addedIndex = tableLoadOptions.Add("sampleTable", 1, 0);
            
            HtmlTableLoadOption option = tableLoadOptions[addedIndex];
            option.TableToListObject = true;

            // Load HTML file (replace with actual file path)
            workbook = new Workbook("input.html", loadOptions);
            workbook.Save("output.xlsx");
        }
    }
}

See Also