Interface ICustomParser
Contents
[
Hide
]ICustomParser interface
Allows users to add their custom value parser for parsing string values to other proper cell value object.
public interface ICustomParser
Methods
Name | Description |
---|---|
GetFormat() | Gets the formatting pattern corresponding to the parsed value by last invocation of ParseObject . |
ParseObject(string) | Parses given string to proper value object. |
Examples
[C#]
namespace Demos
{
using Aspose.Cells;
using System;
public class ICustomParserDemo
{
public static void ICustomParserExample()
{
// Custom parser implementation
ICustomParser customParser = new CustomParser();
// Example usage of ParseObject method
string valueToParse = "123.45";
object parsedValue = customParser.ParseObject(valueToParse);
Console.WriteLine($"Parsed Value: {parsedValue}");
// Example usage of GetFormat method
string format = customParser.GetFormat();
Console.WriteLine($"Format: {format}");
}
}
// Custom implementation of ICustomParser
public class CustomParser : ICustomParser
{
private string lastFormat;
public object ParseObject(string value)
{
// Example parsing logic
if (double.TryParse(value, out double result))
{
lastFormat = "0.00"; // Example format
return result;
}
lastFormat = null;
return null;
}
public string GetFormat()
{
return lastFormat;
}
}
}
See Also
- namespace Aspose.Cells
- assembly Aspose.Cells