Class OdsCellField
Contents
[
Hide
]OdsCellField class
Represents the cell field of ods.
public class OdsCellField
Properties
| Name | Description |
|---|---|
| Column { get; set; } | Get and sets the column index of the cell. |
| CustomFormat { get; set; } | Represents the custom format of the field’s value. |
| FieldType { get; set; } | Gets and sets the type of the field. |
| Row { get; set; } | Get and sets the row index of the cell. |
Examples
namespace AsposeCellsExamples
{
using System;
using Aspose.Cells;
using Aspose.Cells.Ods;
public class OdsClassOdsCellFieldDemo
{
public static void Run()
{
// Create a new workbook and get the first worksheet
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
try
{
// -----------------------------------------------------------------
// 1. Create an OdsCellField via the collection (no parameterless ctor)
// -----------------------------------------------------------------
OdsCellFieldCollection odsFields = sheet.Cells.OdsCellFields;
odsFields.Add(2, 1, OdsCellFieldType.Title, "Demo Title");
// Retrieve the field we just added
OdsCellField manualField = odsFields[odsFields.Count - 1];
// Write something to the cell identified by the OdsCellField
sheet.Cells[manualField.Row, manualField.Column].PutValue("Manual Field");
// --------------------------------------------------------------
// 2. Add the same field again to demonstrate collection usage (optional)
// --------------------------------------------------------------
odsFields.Add(manualField.Row, manualField.Column, manualField.FieldType, manualField.CustomFormat);
// Update all ODS fields so they are reflected in the saved file
odsFields.UpdateFieldsValue();
// Display the property values to the console
Console.WriteLine($"Created OdsCellField -> Row: {manualField.Row}, Column: {manualField.Column}, " +
$"Type: {manualField.FieldType}, Format: {manualField.CustomFormat}");
// Save the workbook as an ODS file
workbook.Save("OdsClassOdsCellFieldDemo.ods");
}
catch (Exception ex)
{
Console.WriteLine($"Error while working with OdsCellField: {ex.Message}");
}
}
}
}
See Also
- namespace Aspose.Cells.Ods
- assembly Aspose.Cells