XLSReadWriteII 5 in C++ Builder XE3

Questions and answers on how to use XLSReadWriteII 5.
Post Reply
mdonath
Posts: 23
Joined: Fri Oct 05, 2012 11:36 am

XLSReadWriteII 5 in C++ Builder XE3

Post by mdonath »

I have installed the new XLSReadWriteII 5 version.

In C++ Builder XE3 I found the following problems:

- In class 'TXLSTokenizer' there is a function 'EOF'. In C++ it is forbidden to have qualifiers which consists of CAPTITALS only. To compile a project, I have to comment this out.
- When reading Excel 2007 files the method 'TXLSWorksheet.CellType' always returns 'xctNone'.

Markus
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: XLSReadWriteII 5 in C++ Builder XE3

Post by larsa »

Hello

The EOF method is removed. Was not used anyway. I can't reproduce the CellType problem. Are you sure that there is a value in the cell you read? If it's empty, CellType will return xctNone.
Lars Arvidsson, Axolot Data
mdonath
Posts: 23
Joined: Fri Oct 05, 2012 11:36 am

Re: XLSReadWriteII 5 in C++ Builder XE3

Post by mdonath »

Hello,

I have downloaded last version (5.10.05), but EOF ist still present.

Here my test code:

Code: Select all

	Xls->Filename = L"test001.xlsx";
	Xls->DirectRead = true;
	Xls->Read();
	try
	{
		for(int s=0; s<Xls->Count(); s++)
		{
			TXLSWorksheet* Sheet = Xls->Sheets[s];
			unsigned LastRow = Sheet->LastRow();
			unsigned LastCol = Sheet->LastCol();
			unsigned FirstRow = Sheet->FirstRow();
			unsigned FirstCol = Sheet->FirstCol();
			for(unsigned r=FirstRow; r<=LastRow; r++)
			{
				for(unsigned c=FirstCol; c<=LastCol; c++)
				{
					TXLSCellType cT = Sheet->CellType[c][r];
					switch(cT)
					{
						case Xc12utils5::TXLSCellType::xctNone:
							Grid->Cells[c+1][r+1] = ColRowToRefStr(c, r);
							break;
						case Xc12utils5::TXLSCellType::xctBlank:
							break;
						case Xc12utils5::TXLSCellType::xctBoolean:
						case Xc12utils5::TXLSCellType::xctBooleanFormula:
							Grid->Cells[c+1][r+1] = Sheet->AsBoolean[c][r] ? L"TRUE" : L"FALSE";
						case Xc12utils5::TXLSCellType::xctString:
						case Xc12utils5::TXLSCellType::xctStringFormula:
							Grid->Cells[c+1][r+1] = Sheet->AsString[c][r];
							break;
						case Xc12utils5::TXLSCellType::xctFloat:
						case Xc12utils5::TXLSCellType::xctFloatFormula:
							if(Sheet->IsDateTime[c][r])
							{
								Grid->Cells[c+1][r+1] = Sheet->AsDateTime[c][r];
							}
							else
							{
								Grid->Cells[c+1][r+1] = Sheet->AsFloat[c][r];
							}
							break;
						case Xc12utils5::TXLSCellType::xctError:
						case Xc12utils5::TXLSCellType::xctErrorFormula:
						{
							TXc12CellError err = Sheet->AsError[c][r];
							Grid->Cells[c+1][r+1] = Xc12CellErrorNames[err];
						} break;
					}
				}
			}
		}
	}
	catch(Exception& e)
	{
		Application->ShowException(&e);
	}

cell type is always xctNone. The file is NOT empty. I will send it per email.

Markus
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: XLSReadWriteII 5 in C++ Builder XE3

Post by larsa »

Hello

You have activated DirectRead. When DirectRead is active, cells are sent trough the OnReadCell event. No cells are stored in memory and hence you will always get xctNone for any cell.

EOF will be removed in the next update. I have however compiled the component with all C++ builder versions from D2007 -> XE3 without any error. Have you enabled some settings before you received the error?
Lars Arvidsson, Axolot Data
mdonath
Posts: 23
Joined: Fri Oct 05, 2012 11:36 am

Re: XLSReadWriteII 5 in C++ Builder XE3

Post by mdonath »

Okay, 'DirectRead' was the problem.


The EOF-problem is shown here:

https://www.dropbox.com/s/lbk1p98gv8jm1jm/EOF.PNG

Markus
Post Reply