Skip to content

Instantly share code, notes, and snippets.

@andy-williams
Created January 6, 2015 13:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andy-williams/0937dc5183549b007486 to your computer and use it in GitHub Desktop.
Save andy-williams/0937dc5183549b007486 to your computer and use it in GitHub Desktop.
CellValuesExtension for OpenXML library
public static class CellValuesExtension
{
public static bool IsBoolean(this EnumValue<CellValues> cellValues)
{
return IsNotEmpty(cellValues) && cellValues.Value == CellValues.Boolean;
}
public static bool IsDate(this EnumValue<CellValues> cellValues)
{
return IsNotEmpty(cellValues) && cellValues.Value == CellValues.Date;
}
public static bool IsString(this EnumValue<CellValues> cellValues)
{
return IsNotEmpty(cellValues) && cellValues.Value == CellValues.String;
}
public static bool IsSharedString(this EnumValue<CellValues> cellValues)
{
return IsNotEmpty(cellValues) && cellValues.Value == CellValues.SharedString;
}
public static bool IsNumber(this EnumValue<CellValues> cellValues)
{
return IsNotEmpty(cellValues) && cellValues.Value == CellValues.Number;
}
public static bool IsInlineString(this EnumValue<CellValues> cellValues)
{
return IsNotEmpty(cellValues) && cellValues.Value == CellValues.InlineString;
}
public static bool IsError(this EnumValue<CellValues> cellValues)
{
return IsNotEmpty(cellValues) && cellValues.Value == CellValues.Error;
}
private static bool IsNotEmpty(EnumValue<CellValues> cellValues)
{
return cellValues != null && cellValues.HasValue;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment