【发布时间】:2013-11-14 19:23:16
【问题描述】:
当我在用户端尝试 exe 时,我遇到了这个问题。用户有 MicosoftExcel 2000,我有 execel 2003。有人可以帮我吗。
我用c#创建了这个工具并使用了COM
if( strDataSheetFile.Trim().EndsWith( ".xls" ) || strDataSheetFile.Trim().EndsWith( ".xlsx" ) )
{
System.IO.StreamWriter file = null;
if (IfAbFile)
{
file = new System.IO.StreamWriter(AbaqusDeckFile.ToString(), true);
}
else
{
string[] strFILEnamesSplit = strDataSheetFile.Split(new Char[] { '\\' });
string ExpFile = "";
int ilnt = 0;
foreach (string strVal in strFILEnamesSplit )
{
if (ilnt < (strFILEnamesSplit.Length - 1))
{
ExpFile += strVal;
ExpFile += "/";
}
else
ExpFile += "Deck.inp";
ilnt += 1;
}
file = new System.IO.StreamWriter(ExpFile.ToString(), true);
}
List<List<double>> List_SheetValues = new List<List<double>>();
Excel.Application objexcel;
Excel.Workbook wbexcel;
Excel.Worksheet wsheet;
objexcel = new Excel.Application();
//strDataSheetFile = @"C:\Ajoy\Demos\IsoMount\IsoMount_Springs_database_updated.xls";
if (File.Exists(strDataSheetFile))
wbexcel = objexcel.Workbooks.Open(strDataSheetFile);
else
{
MessageBox.Show(" Please state the number of springs", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.UseWaitCursor = false;
return;
}
【问题讨论】:
-
看起来,在您的 VBA 代码中,您使用的是在您的机器上注册的类型库,而不是在最终用户机器上。在最终用户计算机上检查参考对话框中是否有任何带有 (missing) 的内容。
-
嗨,JMK,我已经用 C# 编写了这个代码。请问您有什么建议
-
如果没有真正将您的代码放入问题中并确定哪些行给您带来麻烦,我们没有太多工作要做。
-
JMK,我已经发布了我试图打开 excel 文件的部分代码.....