以下の内容はhttps://baba-s.hatenablog.com/entry/2022/09/21/090000より取得しました。


【C#】NPOI でどんなセルの値も文字列で取得できる拡張メソッド

拡張メソッド

using NPOI.SS.UserModel;

namespace Kogane
{
    public static class ICellExtensionMethods
    {
        public static string GetValue( this ICell self )
        {
            if ( self == null ) return string.Empty;

            return self.CellType switch
            {
                CellType.Numeric when DateUtil.IsCellDateFormatted( self ) => self.DateCellValue.ToString(),
                CellType.Numeric                                           => self.NumericCellValue.ToString(),
                CellType.String                                            => self.StringCellValue,
                CellType.Formula                                           => self.CellFormula,
                CellType.Blank                                             => string.Empty,
                CellType.Boolean                                           => self.BooleanCellValue.ToString(),
                CellType.Error                                             => self.ErrorCellValue.ToString(),
                _                                                          => string.Empty,
            };
        }
    }
}



以上の内容はhttps://baba-s.hatenablog.com/entry/2022/09/21/090000より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14