Salve a tutti,
Sto provando a lavorare con C# e excel.
In pratica devo solo aprire un file preesistente e scrivere alcune celle e poi salvarlo.
Ho aggiunto i pia e ora sto provando a lavorare un po con alcuni esempi presi dalla rete
Se però vado ad eseguire il codice mi esce il segiente errore:
"Recupero della class factory COM per il componente con CLSID {00024500-0000-0000-C000-000000000046} non riuscito a causa del seguente errore: 80070005. "
in riferimento alla riga "xlApp = new Excel.Application();"
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;
using System.Web;
using System.IO;
using iTextSharp.text;
using iTextSharp.text.pdf;
using Microsoft.Office.Interop.Excel;
using Microsoft.Office.Interop.Word;
using System.Reflection;
using System.Diagnostics;
using Excel = Microsoft.Office.Interop.Excel;
public partial class Default3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
StartExcelAndSinkEvents();
}
Excel.Application xlApp;
Excel.Workbook xlBook;
Excel.Worksheet xlSheet1, xlSheet2, xlSheet3;
//Excel event delegate variables:
Excel.AppEvents_WorkbookBeforeCloseEventHandler EventDel_BeforeBookClose;
Excel.DocEvents_ChangeEventHandler EventDel_CellsChange;
private void StartExcelAndSinkEvents()
{
//Start Excel, and then create a new workbook.
xlApp = new Excel.Application();
xlBook = xlApp.Workbooks.Add(Missing.Value);
xlBook.Windows.get_Item(1).Caption = "XL Event Test";
xlSheet1 = (Excel.Worksheet)xlBook.Worksheets.get_Item(1);
xlSheet2 = (Excel.Worksheet)xlBook.Worksheets.get_Item(2);
xlSheet3 = (Excel.Worksheet)xlBook.Worksheets.get_Item(3);
xlSheet1.Activate();
........
CHi mi fa capire cosa non va?
Accetto ogni suggerimento....
Rettifica:
Ho risolto come qui indicato.
http://www.dotnethell.it/forum/messages.aspx?ThreadID=7488
è un buon metodo?