以下将 excel 文件(一个工作表;一列)的内容放入需要为 excel 字符串的 DataSet 中:
DataSet ds = excelReader.AsDataSet();
StringWriter sw = new StringWriter();
ds.WriteXml(sw);
string result = sw.ToString();
它返回以下字符串:
<NewDataSet>
<Sheet2><Column1>70209429072734</Column1></Sheet2>
<Sheet2><Column1>30221442748624</Column1></Sheet2>
<Sheet2><Column1>70209433124464</Column1></Sheet2>
<Sheet2><Column1>30209434466634</Column1></Sheet2>
</NewDataSet>
我想要这种格式:
<DLN>
<id>70209429072734</id>
<id>30221442748624</id>
<id>70209433124464</id>
<id>30209434466634</id>
</DLN>