Esempio n. 1
0
        /// <summary>
        /// Gets the cell data.
        /// </summary>
        /// <param name="worksheet">The sheet</param>
        /// <param name="area">The area</param>
        /// <param name="rowIndex">Index of the row</param>
        /// <param name="columnIndex">Index of the column</param>
        /// <param name="opt">The opt</param>
        /// <returns></returns>
        static object GetCellData(Worksheet worksheet, SheetArea area, int rowIndex, int columnIndex, ImportExportOptions opt)
        {
            if (opt.Formula && (area == SheetArea.Cells))
            {
                string formula = worksheet.GetFormula(rowIndex, columnIndex);
                if (!string.IsNullOrEmpty(formula))
                {
                    return(string.Format("={0}", (object[])new object[] { formula }));
                }
            }
            if (!opt.UnFormatted)
            {
                IFormatter formatter = worksheet.GetActualFormatter(rowIndex, columnIndex, area);
                if (formatter != null)
                {
                    return(worksheet.Value2Text(worksheet.GetValue(rowIndex, columnIndex, area), formatter));
                }
            }
            object columnLabel = worksheet.GetValue(rowIndex, columnIndex, area);

            if ((columnLabel == null) && (area == SheetArea.ColumnHeader))
            {
                columnLabel = worksheet.GetColumnLabel(rowIndex, columnIndex);
            }
            if ((columnLabel == null) && (area == (SheetArea.CornerHeader | SheetArea.RowHeader)))
            {
                columnLabel = worksheet.GetRowLabel(rowIndex, columnIndex);
            }
            return(columnLabel);
        }