
25/01/2007, 10:39
|
| | Fecha de Ingreso: diciembre-2006
Mensajes: 32
Antigüedad: 18 años, 2 meses Puntos: 0 | |
error exportando a excel :Object reference not set to an instance of an object protected void ExcelBoton_Click(object sender, ImageClickEventArgs e)
{
Excel.ApplicationClass excel = new ApplicationClass();
excel.Visible = true;
Worksheet worksheet = (Worksheet)excel.ActiveSheet;
Workbooks workbook=(Workbooks)excel.Workbooks;
int col =rec.CargarRecepciones().Columns.Count-1;
int row = rec.CargarRecepciones().Rows.Count - 1;
for (int x = 0; x < col;x++ )
{
// worksheet.Cells[1, x+1] = rec.cargarRecepciones().Columns[x].ColumnName;
for (int y=0;y<row;y++)
worksheet.Cells[y+2,x+1]=rec.CargarRecepciones().Rows[x][y];
}
worksheet.Application.Visible = true;
worksheet.SaveAs("C:\\Recepciones.xls",null,null,n ull,null,null,null,null,null);
excel.Quit();
worksheet=null;
}
debe de ser que el worksheet no está bien hecho. |