admin管理员组文章数量:1583042
using Microsoft.Office.Interop.Excel;
打开Excel
private const string Microsoft_EXCEL_PROG_ID = "Excel.Application";
private const string WPS_EXCEL_PROG_ID = "KET.Application";
if (Type.GetTypeFromProgID(ExcelSoftName) is Type excelType)
{
try
{
app = (Application)System.Runtime.InteropServices.Marshal.GetActiveObject(ExcelSoftName);
}
catch
{
// Excel is not running.
app = (Application)Activator.CreateInstance(excelType);
}
判断 打开的是 wps 还是 微软 office
public bool IsWPSApp()
{
//Path "C:\\Users\\infodator\\AppData\\Local\\Kingsoft\\WPS Office\\11.1.0.9662\\office6" System.String 慢
//StartupPath "C:/Users/infodator/AppData/Local/Kingsoft/WPS Office/11.1.0.9662/office6/startup" System.String 慢
//TemplatesPath "C:/Users/infodator/AppData/Local/Kingsoft/WPS Office/11.1.0.9662/office6/mui/zh_CN/templates" System.String 快
//LibraryPath "C:/Users/infodator/AppData/Local/Kingsoft/WPS Office/11.1.0.9662/office6/library" System.String 快
//ExcelBot.Shared.App.Path "C:\\Program Files\\Microsoft Office\\Root\\Office16" string 慢
//ExcelBot.Shared.App.StartupPath "C:\\Users\\infodator\\AppData\\Roaming\\Microsoft\\Excel\\XLSTART" string 慢
//ExcelBot.Shared.App.TemplatesPath "C:\\Users\\infodator\\AppData\\Roaming\\Microsoft\\Templates\\" string 快
//ExcelBot.Shared.App.LibraryPath "C:\\Program Files\\Microsoft Office\\Root\\Office16\\LIBRARY" string 快
return ExcelBot.Shared.App.TemplatesPath.ToLower().Contains("wps");
}
本文标签: 的是微软InteropMicrosoftoffice
版权声明:本文标题:c# Microsoft.Office.Interop.Excel 判断使用的是 wps office 还是 微软office 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/xitong/1727905882a1137396.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论