Hi
Can someone provides a small example on how to handle rotation definition to a cell? Your documentation says we have to pass a byte. I was not able to find any documentation on the proper way to do this. Obviously, it is not just the degree assignation as this does not work. I would assume that TFlxFormatHeader.Rotation=90 would have worked. But, this byte issue is complicating things.
Thanks
Hi,
Hi
Well, lets make it simple. In Excel, I have set it up to -90. So, if I set this has is in Flexcel, it gives "Arithmetic operation resulted in an overflow.". If I tried 270, it gives "Arithmetic operation resulted in an overflow.". So, how am I suppose to have the support for -90 in Flexcel?
The previous message also did not detail anything about the byte syntax that would need to be used if I would want to use it.
The help shown in your message, I already saw it. But, that is useless for -90.
What is APIMate? Is that a tool from your company?
Hi,
Hi
This works. But, I have to handle it like this:
' Initialization
lnDegree = loRow("Degree")
' If this is negative
If lnDegree < 0 Then
lnDegree = 270 - (180 + lnDegree)
End If
loTFlxFormatHeader.Rotation = lnDegree
So, basically, if I understood correctly, if the user enters a negative value, which represents exactly what they would put in Excel, I would have to apply this formula so it would match your utility.
You have to understand that users are using a framework data entry form to enter values in the database for the cell properties. They will enter is exactly as if they would be in Excel. So, in Excel, for that one, it is -90. However, to your utility, -90 is not accepted and we have to apply a formula.
I just do not understand why this is not a direct assignation with the same value as if we would be in Excel.
Thanks for the information on APIMate. That would be useful.
Hi,
lnDegree = loRow("Degree")
' If this is negative
If lnDegree < 0 Then
lnDegree = 270 - (180 + lnDegree)
End If
Hi
Yes, this is what my framework does. It contains a Report class which is a high level class to yours and allows the user to enter the degree as if he would be in Excel. Then, the high level class simply converts it.
However, instead of applying that formula, this byte thing is still a mystery. You mentioned that if I would work with a byte, I wouldn't have to apply that conversion. Could you provide an example in VB.NET on how to define this byte and pass it to the Rotation property?
I would ratter much like to have something like that then to have this mathematical conversion.
Also, yes, you are right. Any little overhead will add extra CPU time. Recently, I adjusted the way the report were constructed as the old developer did a lot of unnecessary calls to Flexcel. That dropped the time from 40%.
In regards to that, presently, I generate a 40 MB report. That is a .xlsx format. This is a binary format. My SQL select command takes about 0.8 seconds to gather thousands of records. However, it takes about 75 seconds to build the report. Is the upcoming version providing a faster processing on the cell initialization, which I believe is what takes time?
About the byte thing, what I was just saying is that in an xls file (the only files that existed when we designed the TFlxFormat structure), the rotation is stored as a byte in the file. So FlexCel just reads the bytes from the xls file and stores them into memory, without further processing.
Hi
Not really, my framework handles all the metrics and the SQL portion is 0.8 second, than about 75 seconds are required for the Flexcel part. I was able to gain a few seconds by using SetCellValue() everywhere. On condition, it was either SetCellValue() or SetCellFromString(). Now, I use only the one you suggested. Are you saying that SetCellFromString() is deprecated?
As far as saving the data directly into a text file, I will have to do some tests.
We upgraded to bypass the 65k limit. It has proven to work very well.
Hi
The data is in memory. Flexcel does not talk to SQL Server directly. I initialize all cells into a For/Next for each column inside a For/Next for each row. From a dataset, then, I set the value by using Flexcel.
Or, maybe I missed something in what you are trying to say.
After another test I just did, just using SetCellValue() is not good enough. I am loosing the format I have applied to several ranges such as for currencies.
For example, in my code I have something like this:
' Based on the type of field
Select Case loField.Type
' Character, memo, NVarChar, VarChar, Varchar(MAX), NVarchar(MAX)
Case "C", "M", "O", "V", "X", "Y"
' Integer
Case "I"
' Numeric
Case "N"
' If this is a dollar amount field
If loField.Dollar Then
lcFormatGenerated = "$#,##0.00;$#,##0.00"
Else
lcFormatGenerated = "#,##0.00;#,##0.00"
End If
' Date, Datetime
Case "D", "T"
lcFormatGenerated = "yyyy/mm/dd hh:mm:ss"
' Boolean
Case "L"
' Binary
Case "E"
' Big integer
Case "B"
' Else
Case Else
End Select
And, then below, I need to verify if I force the data to be sent as a string or not:
' If we display as string
If llDisplayAsString Then
' Initialize the value in the cell
oXlsFile.SetCellValue(lnCounter + 2, lnColumn, lcValue)
Else
' Initialize the value in the cell
oXlsFile.SetCellFromString(lnCounter + 2, lnColumn, lcValue)
End If
This makes sure that the currency values, for the columns showing amounts, will be set ok by preserving the format I have defined. In the latest test, when I used only SetCellValue(), it ignored my formatting, put everything left aligned and got rid of the dollar sign.
Still not sure about the reference when you mention "if you are reading the values from a database". Yes, I do. But, this goes in a dataset and then I set all cells one by one.
Hi
Ok, I understand what you are saying.
I got confused by an old developer who converted the data to a string for 100% of the cell initialization. So, I have adjusted that, simplified all this and now the code only uses SetCellValue() which is saving 20% of CPU time.