using System;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
using Microsoft.Office.Core;
using Excel = Microsoft.Office.Interop.Excel;
namespace Excelreader
{
[Guid("8db383a3-7a57-40bb-b943-68ce057fe8ad")]
public class Excelreader : System.Web.UI.WebControls.WebParts.WebPart
{
public void Open()
{
string filename = "MeinPfad";
Excel.Application exlApp = new Excel.Application();
Excel.Workbook wb = exlApp.Workbooks.Open(filename, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
//Ersters Worksheet öffnen
Excel.Worksheet wc = (Excel.Worksheet)wb.Worksheets[1];
//Hier dann auf die entsprechenden Spalten und Zeilen zugreifen
Marshal.ReleaseComObject(wc);
wb.Close(false, Type.Missing, Type.Missing);
Marshal.ReleaseComObject(wb);
exlApp.Quit();
Marshal.ReleaseComObject(exlApp);
}
protected override void Render(HtmlTextWriter writer)
{
}
}
}