简体   繁体   中英

SpreadsheetLight get an excel cell value beginning with aposthrope

When I read an excel cell value using SpreadsheetLight - I get the cell value without the leading apostrophe. When the cell value is 'Something I only get Something. I understand that the apostrophe has a special meaning for excel - but I really need that char! :)

How to detect when a cell has a leading apostrophe? I use the GetCellValueAsString(...) function to retrieve cell value.

The leading apostrophe went to the cell style data to the QuotePrefix property.

if (sl.HasCellValue(rowIndex, i + 1))
{
    var style = sl.GetCellStyle(rowIndex, i + 1);
    var text= sl.GetCellValueAsString(rowIndex, i + 1);
    Row[i] = (style.QuotePrefix.HasValue && style.QuotePrefix.Value) ? "'" + text : text;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM