try { string filename = ""; SaveFileDialog op = new SaveFileDialog(); op.Filter = "Exel|*.xls"; if (op.ShowDialog() == DialogResult.OK) { filename = op.FileName; StreamWriter wr = new StreamWriter(filename); for (int i = 0; i < DetailsView.Columns.Count; i++) { wr.Write(DetailsView.Columns[i].Text); wr.Write("\t"); } wr.Write("\n"); for (int r = 0; r < DetailsView.Items.Count - 1; r++) { for (int c = 0; c < DetailsView.Columns.Count; c++) { wr.Write(DetailsView.Items[r].SubItems[c].Text.ToString()); wr.Write("\t"); } wr.Write("\n"); } wr.Close(); } System.Diagnostics.Process.Start(filename); } catch (SystemException io) { MessageBox.Show(io.Message); }
Quote:this program is working but last entry in listview is not import to excel please help me ..
-1
for (int r = 0; r < DetailsView.Items.Count - 1; r++)
<=
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)