OoxmlSaveOptions.AsFlatOpc

OoxmlSaveOptions.AsFlatOpc property

Indicates whether saving as a flat opc file which can be generated by Open XML SDK.

public bool AsFlatOpc { get; set; }

Examples

namespace AsposeCellsExamples
{
    using Aspose.Cells;
    using System;

    public class OoxmlSaveOptionsPropertyAsFlatOpcDemo
    {
        public static void Run()
        {
            // Create a new workbook
            Workbook workbook = new Workbook();

            // Access first worksheet
            Worksheet worksheet = workbook.Worksheets[0];

            // Add some data to make the example meaningful
            worksheet.Cells["A1"].PutValue("Sample Data");
            worksheet.Cells["B1"].PutValue("Flat OPC Demo");

            try
            {
                // Create OoxmlSaveOptions instance
                OoxmlSaveOptions saveOptions = new OoxmlSaveOptions();

                // Display the default value of AsFlatOpc property
                Console.WriteLine("Default AsFlatOpc value: " + saveOptions.AsFlatOpc);

                // Set AsFlatOpc to true
                saveOptions.AsFlatOpc = true;
                Console.WriteLine("AsFlatOpc set to: " + saveOptions.AsFlatOpc);

                // Save the workbook with AsFlatOpc enabled
                workbook.Save("AsFlatOpc_Enabled.xlsx", saveOptions);

                // Create another save options with AsFlatOpc disabled
                OoxmlSaveOptions saveOptions2 = new OoxmlSaveOptions();
                saveOptions2.AsFlatOpc = false;
                Console.WriteLine("AsFlatOpc set to: " + saveOptions2.AsFlatOpc);

                // Save the workbook with AsFlatOpc disabled
                workbook.Save("AsFlatOpc_Disabled.xlsx", saveOptions2);

                Console.WriteLine("AsFlatOpc property demonstration completed successfully.");
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error: {ex.Message}");
            }
        }
    }
}

See Also