我希望能够选择我的Excel文件的标题以及特定的行和格式到xml文件。我如何选择该范围的单元格并获取我的标题?这是我必须选择文件和整个工作表到数据集然后xml转换。
public void getXML()
{
...................
OleDbConnection objConn = new OleDbConnection(connection);
OleDbCommand objCmd = new OleDbCommand(string.Format(@"Select * From [Sheet1$]"), objConn);
^^^
//Need to select header plus set of custom cells. like A6: O6
OleDbDataAdapter objDatAdap = new OleDbDataAdapter();
objDatAdap.SelectCommand = objCmd;
DataSet ds = new DataSet();
objDatAdap.Fill(ds);
string result;
using (StringWriter sw = new StringWriter())
{
ds.WriteXml(sw);
result = sw.ToString();
}
}