1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
using namespace System;
using namespace System::IO;
using namespace System::Data;
using namespace EasyXLS;
using namespace System::Text;
int main()
{
Console::WriteLine("Tutorial 34\n----------\n");
ExcelDocument ^workbook = gcnew ExcelDocument();
Console::WriteLine("Reading file C:\\Samples\\Tutorial09.xlsx.\n");
DataSet ^ds = workbook->easy_ReadXLSXActiveSheet_AsDataSet("C:\\Samples\\Tutorial09.xlsx");
String ^sError = workbook->easy_getError();
if (sError->Equals(""))
{
DataTable ^dt = ds->Tables[0];
StringBuilder ^str;
for (int row=0; row < dt->Rows->Count; row++)
{
for (int column=0; column < dt->Columns->Count; column++)
{
str = gcnew StringBuilder();
str->Append(String::Concat("At row ", (row + 1).ToString(), ", column ", (column + 1).ToString()));
str->Append(String::Concat(" the value is '",
Convert::ToString(dt->Rows[row]->ItemArray[column]), "'"));
Console::WriteLine(str);
}
}
}
else
Console::Write(String::Concat("\nError reading file C:\\Samples\\Tutorial09.xlsx \n", sError));
delete workbook;
Console::Write("\nPress Enter to Exit...");
Console::ReadLine();
return 0;
}
|