XML Dosyasini C# İle Excel Cevirme(Yardim)
-
bu konu hakında hakında bilgisi olan varmi ?
-
yokmu arkadaslar bu konu hakkında bilgisi olan raporlama icin kulanılacak ?
-
http://www.codeproject.com/KB/office/excel2xml.aspx
http://www.codeproject.com/KB/office/excelxmlspreadsheet.aspx
-
tesekurler yardımin icin
-
gridview den excel e atmak ıcın
bu foksıyon kulanılıyor
private void ToCsV(DataGridView ds, string filename)
{
string stOutput = "";
// Export titles:
string sHeaders = "";
for (int j = 0; j < ds.Columns.Count; j++)
sHeaders = sHeaders.ToString() + Convert.ToString(ds.Columns[j].HeaderText) + "\t";
stOutput += sHeaders + "\r\n";
// Export data.
for (int i = 0; i < ds.RowCount-1; i++)
{
string stLine = "";
for (int j = 0; j < ds.Rows.Count; j++)
{
stLine = stLine.ToString() + Convert.ToString(ds.Rows[i].Cells[j].Value) + "\t";
}
stOutput += stLine + "\r\n";
}
Encoding utf16 = Encoding.GetEncoding(1254);
byte[] output = utf16.GetBytes(stOutput);
FileStream fs = new FileStream(filename, FileMode.Create);
BinaryWriter bw = new BinaryWriter(fs);
bw.Write(output, 0, output.Length); //write the encoded file
bw.Flush();
bw.Close();
fs.Close();
}butonun ıcıne ıse
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "Text Documents (*.txt)|*.txt";
sfd.FileName = "export.txt";
if (sfd.ShowDialog() == DialogResult.OK)
{
ToCsV(dataGridView1, @"c:\export.xls");
ToCsV(dataGridView1, sfd.FileName);
}bu kod yazılıyor hepsınıze kolay gelsın