Entwickler-Ecke

Sonstiges (.NET) - DataGridView Data to Excel by using Excel Object


tomycat - Mo 09.05.16 20:03
Titel: DataGridView Data to Excel by using Excel Object
hallo,
ich möchte gerne den Inhalt von einem datagridview in einer Excel Datei speichern.

Meine Vorlage:
https://code.msdn.microsoft.com/office/How-to-Export-DataGridView-62f1f8ff


C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
......
        private void ExportToExcel()
        {
            // Creating a Excel object.
            Microsoft.Office.Interop.Excel._Application excel = new Microsoft.Office.Interop.Excel.Application();       
            Microsoft.Office.Interop.Excel._Workbook workbook = excel.Workbooks.Add(Type.Missing);
            Microsoft.Office.Interop.Excel._Worksheet worksheet = null;

            try
            {
......


Alle Wörter mit Office sind Rot unterschriechen.
Laut google suche soll ich : add ref. > Microsoft.Office... // gibts es aber nicht.

o2010pia.exe habe ich auch installiert, aber ohne Erfolg.

Moderiert von user profile iconChristian S.: Code- durch C#-Tags ersetzt
Moderiert von user profile iconTh69: Beitragsformatierung überarbeitet (und .NET Version auf 4.5 gesetzt, anstatt Silverlight).


Ralf Jansen - Mo 09.05.16 20:20

Wenn ich das richtig in Erinnerung habe wirst du beim Visual Studio Setup gefragt ob du die Office Developer Tools mit installieren willst. Am besten nochmal das Setup starten und die mit auswählen.
Je nach Version von Visual Studio (ie. Express und/oder Cmmunity) sind die aber möglicherweise nicht dabei.


tomycat - Mo 09.05.16 20:36

hab setup (vs2015)nochmal ausgeführt, leider gibts kein office blabla


Ralf Jansen - Mo 09.05.16 20:45

Wenn es da ist dann hier

vs2015setup


tomycat - Mo 09.05.16 21:09

naja du hast die Prof :-)
Der Tipp -----------> Office Developer Tools......war Goldwert !!!
Für alle die nicht die Prof 2015 haben:
https://www.visualstudio.com/de-de/features/office-tools-vs.aspx


Ralf Jansen - Mo 09.05.16 21:13

oh äh ja klar .... oder einfach runterladen :oops: