I read sheet by sheet of a sheet, and I stored it in a DataSet . I'm having trouble passing this DataSet data to another worksheet. Can someone help me ? I have the second code:
conn.Open();
string strConexao = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=0\"", localArquivo);
DataTable dt = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });
DataSet output = new DataSet();
foreach (DataRow row in dt.Rows)
{
// obtem o noma da planilha corrente
string sheet = row["TABLE_NAME"].ToString();
// obtem todos as linhas da planilha corrente
OleDbCommand cmd = new OleDbCommand("SELECT * FROM [" + sheet + "]", conn);
cmd.CommandType = CommandType.Text;
// copia os dados da planilha para o datatable
DataTable outputTable = new DataTable(sheet);
output.Tables.Add(outputTable);
new OleDbDataAdapter(cmd).Fill(outputTable);