获取有关所需成员的错误

时间:2016-04-05 10:15:15

标签: visual-studio winrt-xaml

我正在Visual Studio 2013中开发Windows 8.1应用程序,以便在运行时创建Excel工作表。 Visual Studio不显示任何错误,但是当我运行应用程序时,会出现运行时错误:

  

错误1缺少编译器所需的成员   'System.Runtime.InteropServices.LCIDConversionAttribute..ctor'D:\ GS \ Projects \ excel \ excel \ CSC excel

这是我的CS代码:

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238

namespace excel
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class MainPage : Page
    {
        public MainPage()
        {
            this.InitializeComponent();
            Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();
            Microsoft.Office.Interop.Excel.Workbook workbook = null;
            Microsoft.Office.Interop.Excel.Workbooks workbooks = null;
            Microsoft.Office.Interop.Excel._Worksheet worksheet = null;
            workbooks = excelApp.Workbooks;
            workbook = workbooks.Add(1);
            worksheet = (Microsoft.Office.Interop.Excel.Worksheet)workbook.Sheets[1];
            excelApp.Visible = true;
            worksheet.Cells[1, 1] = "Value1";
            worksheet.Cells[1, 2] = "Value2";
            worksheet.Cells[1, 3] = "Addition";
        }
    }
}

在上面的代码中,VS-2013中没有显示红线表示错误。 我添加了Excel的参考资料:Microsoft.Office.Interop.Excel

有没有人有解决方案?

1 个答案:

答案 0 :(得分:0)

很抱歉,您无法通过商店应用自动化办公室。如果你想创建一个电子表格,我会看看像syncfusion的docio这样的东西