Tak ted to nechápu, ale něco jsem omylem smáznul a začlo to makat... Zde je funkční kód:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.OleDb;
using System.Data;
using System.Web;
namespace Objekt
{
public class test
{
public static string getText()
{
/* String sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Server.MapPath("data.xls") + ";Extended Properties=\"Excel 8.0;HDR=No\"";
OleDbConnection objConn = new OleDbConnection(sConnectionString); */
String sConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + (HttpContext.Current.Server.MapPath ("data.xls")) + ";Extended Properties=\"Excel 8.0;HDR=No\"";
OleDbConnection objConn = new OleDbConnection(sConnectionString);
objConn.Open();
OleDbCommand objCmdSelect = new OleDbCommand("SELECT * FROM [List1$B2:B2]", objConn);
object nazev = objCmdSelect.ExecuteScalar();
return nazev.ToString();
objConn.Close();
}
}
}