Guten Abend!
Der Text aus den einzelnen Zellen meines DataViewGrids wird artig ins Excel portiert,
nur eine Bitmap(Bild eines Barcodes), will einfach nicht im Excel landen.
Es steht in der vorgesehenen Excelspalte dann nur:
System.Bitmap.Drawing
Meine Instanz ExcelApp bietet mir nichts wie:
sheet.Shapes.AddPicture
Codeausschnitt:
[highlight=c#]Microsoft.Office.Interop.Excel.ApplicationClass ExcelApp
new Microsoft.Office.Interop.Excel.ApplicationClass();
ExcelApp.Application.Workbooks.Add(Type.Missing);
ExcelApp.Columns.ColumnWidth = 30;
//Reihen befüllen i=0 äussere Schleife damit Grid ab Row0 gedruckt wird
for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
{
DataGridViewRow row = this.dataGridView1.Rows[i];
for (int j = 0; j < row.Cells.Count; j++)
{
ExcelApp.Cells[i + 2, j + 1] = row.Cells[j].FormattedValue.ToString();
//Versuch Bitmap zu speichern in Excel Zelle 5
ExcelApp.Cells[i + 2, row.Cells.Count + 1] = (Bitmap)row.Cells[4].Value;
}
}
ExcelApp.ActiveWorkbook.SaveCopyAs(saveFileDialog1 .FileName);
ExcelApp.ActiveWorkbook.Saved = true;
ExcelApp.Quit();[/highlight]
Test: Bitmap kann korrekt auf Festplatte gespeichert werden
[highlight=c#]// Durch Casting - mit Bitmap wird das schon vorhandene Barcode Bitmap aus der cell[4] geholt
Bitmap c = new Bitmap((Bitmap)row.Cells[4].Value);
// Entsteht Bitmap - - wird auf Festplatte gespeichert - sDateiname
c.Save(sDateiname, System.Drawing.Imaging.ImageFormat.Bmp);*/[/highlight]
Frage:
Wie bekomme ich die Bitmaps in die Excelliste in eine bestimmte Spalte?
Was mache ich falsch?
LG
glorias
Der Text aus den einzelnen Zellen meines DataViewGrids wird artig ins Excel portiert,
nur eine Bitmap(Bild eines Barcodes), will einfach nicht im Excel landen.
Es steht in der vorgesehenen Excelspalte dann nur:
System.Bitmap.Drawing
Meine Instanz ExcelApp bietet mir nichts wie:
sheet.Shapes.AddPicture
Codeausschnitt:
[highlight=c#]Microsoft.Office.Interop.Excel.ApplicationClass ExcelApp
new Microsoft.Office.Interop.Excel.ApplicationClass();
ExcelApp.Application.Workbooks.Add(Type.Missing);
ExcelApp.Columns.ColumnWidth = 30;
//Reihen befüllen i=0 äussere Schleife damit Grid ab Row0 gedruckt wird
for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
{
DataGridViewRow row = this.dataGridView1.Rows[i];
for (int j = 0; j < row.Cells.Count; j++)
{
ExcelApp.Cells[i + 2, j + 1] = row.Cells[j].FormattedValue.ToString();
//Versuch Bitmap zu speichern in Excel Zelle 5
ExcelApp.Cells[i + 2, row.Cells.Count + 1] = (Bitmap)row.Cells[4].Value;
}
}
ExcelApp.ActiveWorkbook.SaveCopyAs(saveFileDialog1 .FileName);
ExcelApp.ActiveWorkbook.Saved = true;
ExcelApp.Quit();[/highlight]
Test: Bitmap kann korrekt auf Festplatte gespeichert werden
[highlight=c#]// Durch Casting - mit Bitmap wird das schon vorhandene Barcode Bitmap aus der cell[4] geholt
Bitmap c = new Bitmap((Bitmap)row.Cells[4].Value);
// Entsteht Bitmap - - wird auf Festplatte gespeichert - sDateiname
c.Save(sDateiname, System.Drawing.Imaging.ImageFormat.Bmp);*/[/highlight]
Frage:
Wie bekomme ich die Bitmaps in die Excelliste in eine bestimmte Spalte?
Was mache ich falsch?
LG
glorias
Comment