我正在使用OPENXML SDK 2.0来流式传输电子表格文件。源数据来自数据表,然后使用openxml将其写入电子表格。如果数据表中的某一列数据具有 " Treshold%"(该文本在前面有制表符空格),则会将其写入 Excel 中,但在 Excel 单元格中将其写为 "Treshold%" 并删除制表符空格。
我正在使用以下代码。使用
我正在使用以下代码。使用
workSheetWriter.PasteText
和workSheetWriter.PasteValue
方法。WorksheetWriter workSheetWriter = new WorksheetWriter(spreadSheet, workSheet);
int intValue = 0;
if (strValue.Contains("$"))
{
strValue = strValue.Replace("$", "");
strValue = strValue.Replace(",", "");
workSheetWriter.PasteValue(cellLocation, strValue, CellValues.Number);
}
else if (int.TryParse(strValue, out intValue))
{
workSheetWriter.PasteValue(cellLocation, strValue, CellValues.Number);
}
else if (string.IsNullOrEmpty(strValue))
{
workSheetWriter.PasteText(cellLocation, strValue);
}
else
{
workSheetWriter.PasteText(cellLocation, strValue);
}
请帮忙解决这个问题。如何将以一个制表符( Treshold%)开头的数值写入Excel单元格,使其保持相同的格式?