AxisTitle.Textプロパティを設定しようとすると、COM Interop経由でExcelにデータをエクスポートするとエラー(コード0x800A03EC)が表示されます。これはWindows 7 x64 ProfessionalとExcel 2003の特定のコンピュータでのみ発生します。さまざまな種類のPC(Win7 x64 Professional + Excel 2003を含む)で試しましたが、他のマシンでそのエラーを再現することはできません。COMException軸のタイトルを設定すると0x800A03EC
private static void setAxisTitle(_Chart tChart, string aszTimeUnit)
{
Axis tAxis = (Axis)tChart.Axes(XlAxisType.xlValue, XlAxisGroup.xlPrimary);
try
{
tAxis.HasTitle = true;
tAxis.AxisTitle.Text = "Messwert [um/m]";
tAxis = (Axis)tChart.Axes(XlAxisType.xlCategory, XlAxisGroup.xlPrimary);
tAxis.HasTitle = true;
tAxis.AxisTitle.Text = string.Format("Zeit [{0}]", aszTimeUnit);
}
catch (Exception aEx)
{
cLogger.ErrorFormat("error setting axis title for time unit '{0}' on Axis '{1}'", aszTimeUnit, tAxis.AxisTitle);
cLogger.Error("error stack trace:", aEx);
throw;
}
}
誰かがこのジレンマを解決する方法を知っていますか?
EDIT: 異なる文化のトピックについて: OSとExcelの文化は同じです。
static Excel2007Export()
{
Microsoft.Office.Interop.Excel.Application tExcel = new Application();
cSystemCulture = Thread.CurrentThread.CurrentCulture;
cExcelCulture = new CultureInfo(tExcel.LanguageSettings.get_LanguageID(
Microsoft.Office.Core.MsoAppLanguageID.msoLanguageIDUI));
try
{
Thread.CurrentThread.CurrentCulture = cExcelCulture;
int tVersion;
bool tParseSucceded = Int32.TryParse(tExcel.Version.Substring(0, tExcel.Version.IndexOf('.')), out tVersion);
// 12 is the first version with .xlsx extension
if (tVersion >= 12)
cDefaultExtension = ".xlsx";
else
cDefaultExtension = ".xls";
}
catch (Exception aException)
{
cLogger.Debug("error retrieving excel version.", aException);
cLogger.Error("error retrieving excel version.");
}
finally
{
Thread.CurrentThread.CurrentCulture = cSystemCulture;
}
}
これは、多くのことを意味する非常に虚偽のExcelエラーです。あなたはGoogleの "Excelのエラー1004"をすることができますが、掘り起こすために多くのcruftがあります。 4階建ての窓から機械を落とすこともできます。がんばろう。 –
@Hans:ROFL :-) +1その正直な答え – yas4891
両方のマシンに同じサービスパックがありますか? – code4life