Excel把数据存入共享字符串文件中并返回该字符串的下标

时间:2024-06-06 09:35:44
         public static int InsertSharedStringItem(string text, pkg.SharedStringTablePart shareStringPart)
{
if (shareStringPart.SharedStringTable == null)
{
shareStringPart.SharedStringTable = new DOS.SharedStringTable();
} int i = ; foreach (DOS.SharedStringItem item in shareStringPart.SharedStringTable.Elements<DOS.SharedStringItem>())
{
if (item.InnerText == text)
{
return i;
}
i++;
} shareStringPart.SharedStringTable.AppendChild(new DOS.SharedStringItem(new DOS.Text(text)));
shareStringPart.SharedStringTable.Save(); return i;
}