我正在使用OPENXML SDK 2.0來傳輸電子表格文件。源數據來自數據表並使用openxml將其寫入Spreadsheet。如果有一個數據表的列數據中有一個具有「Treshold%」(此文本上有標籤空間)並且寫入excel相同,但是將它寫入到「Treshold%」 in excel單元格和刪除標籤空間。OpenXML電子表格 - 在寫入單元格值時在值之前或之後保留空格
我使用的代碼如下。使用workSheetWriter.PasteText
和方法。
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);
}
請幫忙。如何將開始的tab空間值(Treshold%)寫入excel單元格的格式爲相同的格式?