1Danke
ERLEDIGT
JA
JA
ANTWORTEN
6
6
ZUGRIFFE
8916
8916
EMPFEHLEN
-
Hi,
ich habe eine DataGridView, die mir aus einer MS-SQL DB Daten anzeigt.
Das Grid ist in ASP.Net 2.0 in einer aspx seite erstellt.
Ich will einen Button, der genau aus dieser Tabelle eine Excel Datei mit dem Inhalt des DataGridViews erstellt.
Ist das Möglich?
Wenn ja wie?
Besten Dank
-
Hi nochmals,
es langt eigentlich auch wenn ich die Tabelle GridView1 in den zwischenspeicher kopieren könnte!
-
die antwort liegt bei:
www.gridviewguy.com
da liegen noch mehrere AWs
-
09.01.08 19:30 #4
- Registriert seit
- Sep 2005
- Beiträge
- 1
ich würde genau sowas für c# und forms brauchen, finde aber bei gridviewguy nix
bin ich nur blind, oder findet man dort nur ASP.NET artikel?!
need help!
thnx
-
23.07.09 11:19 #5Gast Tutorials.de Gastzugang
Hallo,
du findest unter http://www.ploetzeneder.eu/softwaree...portieren.html eine Loesung wie du diese Daten in Excel exportieren kannst. Ich hoffe ich kann dir damit weiterhelfen.
-
23.07.09 11:33 #6
Ich habs folgendermaßen gemacht:
1. Verweise dem Projekt hinzufügen
- Microsoft.Office.Core
- Microsoft.Office.Interop.Excel
- Office
2. Code zum DataGridView(aDataGridView) in Excel speichern
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
private void toolStripButtonExcel_Click(object sender, EventArgs e) { if (saveFileDialog1.ShowDialog() == DialogResult.OK) { Microsoft.Office.Interop.Excel.ApplicationClass ExcelApp = new Microsoft.Office.Interop.Excel.ApplicationClass(); ExcelApp.Application.Workbooks.Add(Type.Missing); ExcelApp.Columns.ColumnWidth = 20; int k = 0; foreach (DataGridViewColumn column in aDataGridView.Columns) { ExcelApp.Cells[1, k + 1] = column.HeaderText.ToString(); k++; } for (int i = 2; i < aDataGridView.Rows.Count; i++) { DataGridViewRow row = aDataGridView.Rows[i]; for (int j = 0; j < row.Cells.Count; j++) { ExcelApp.Cells[i + 1, j + 1] = row.Cells[j].FormattedValue.ToString(); } } ExcelApp.ActiveWorkbook.SaveCopyAs(saveFileDialog1.FileName); ExcelApp.ActiveWorkbook.Saved = true; ExcelApp.Quit(); } }What was hard to code should be hard to read, too******
-
Klappt super. Dankeschön!
Ähnliche Themen
-
DataTable/ DataGridView nach Excel exportieren
Von jimboo im Forum .NET Windows FormsAntworten: 15Letzter Beitrag: 18.07.10, 21:02 -
Excel Werte in anderes Excel exportieren
Von Sebastian Thalhammer im Forum Office-AnwendungenAntworten: 9Letzter Beitrag: 28.05.10, 13:24 -
Daten von Excel zu Datagridview importieren
Von hausmeister079 im Forum .NET DatenverwaltungAntworten: 1Letzter Beitrag: 05.01.10, 12:56 -
[C#] DataGridView, Zellen wie bei Excel formatieren
Von chris_de_luxe im Forum .NET Windows FormsAntworten: 1Letzter Beitrag: 12.01.09, 15:14 -
DataTable/DataGridView nach Excel
Von Gibson0565 im Forum .NET DatenverwaltungAntworten: 3Letzter Beitrag: 18.06.07, 20:11





Zitieren
Login





