Free Support Forum - aspose.com

URGENT: Problem copying sheets with 4.4.1.3

Hi,

today we have encountered an issue in that we are unable to copy a sheet to another Workbook (see attached example). However, earlier versions of the Workbooks worked just fine. Switching to anything on or after 4.4.1.7 isn’t an option for us as this one has the huge Style vs GetStyle/SetStyle change.

Please advise. We need to perform reporting using these files.

Thanks in advance.

Kai

Hi,

We found the issue and will fix it soon.

For Style Vs GetStyle/SetStyle change, we did sacrifice and eliminate Style attribute from Cell class and we have now GetStyle and SetStyle methods instead which are more optimized with enhanced performance. So, I think you may try to use Find...Replace dialog for your need and modify the code accordingly.

Thank you.

Hi,

with regards to the naming of the Sheet, please use “Balance Sheet - Assets” this will yield the exact same problem.

BTW: To quickly get all of this resolved, we would need to go through a couple of hundred lines of code to work around this and get Style vs. GetStyle/SetStyle fixed. This would require a huge amount of retesting.

I am not particularily happy with breaking interfaces so often.

However if there’s a fix for this problem and this is the only option for us to migrate, it must be ascertained that if we stumble over new issues, we need the usual quick turn around times to get this fixed. Because when we start migrating, there’s no way back for us to the old Style Property

Thanks

Kai

Hi Kai,

Could you change your codes as following:

Worksheet targetSheet = container.Worksheets[name];
Worksheet sourceSheet = source.Worksheets[name];

We find there is a bug when the sheet copy itself in the old version.

We will fix this bug in the new fix and we will keep the Cell.Style property. Thanks for your patice.

Warren,

appologies!!! The sample was more than wrong, of course. Ok, I have looked at it again. You are right, I want to copy from source to container. When I fixed that the code worked. However it seems in my live environment it didn’t, and now I know why. Please look at the attached sample. When I open the files in Aspose, save them and reopen them in Aspose and then do the copy, it fails. Looks as if Opening / Saving the files breaks them.

You may see the code working when you comment out the block that saves and reopens the files. Then the copy works.

Kai

Hi Kai,

Thanks for your info.We have found this issue in the old version.But this issue is removed in the new version.

We will post a new fix(which contains Cell.Style property) soon. So you don't need to change your codes .

Thanks for your patience.

Warren,

thanks for this. I would assume that the old/new Style property would simply call GetStyle() / SetStyle() which should yield the same results, right?

Kai

Hi Kai,

Yes, you may utilize Cell.Style property but using separatedly Cell.GetStyle and Cell.SetStyle certainly are better choices for performance optimization in the long run. We have fixed your issue related Copying worksheets as all our test cases succeeded. Please try the attached version (4.4.1.9) and we also retain Cell.Style property in this fix, so, you don't need to modify / change your code any more.

Thank you.

Thanks for the fix. Will test ist right away.

However, I am curious now: Can you explain why using Getters and Setters is better than using a Property? I don’t get it.

Also, the Rows and Columns properties have been removed from the Cells class. What should I be using to get the number of columns / rows now? MaxRows / MaxColumns, MaxDataRows / MaxDataColumns?

Thanks

Kai

BTW: As the hole Columns / Rows properties have been gone from the Cells class, how can I easily copy the whole style of a row to another? Say, style of one cell to a whole row of cells?

Like so:

paramExcelOutput.Styles[style].Copy(paramExcelOutput.Worksheets[paramSheetName].Cells.Rows[oldRow].Style );


Thanks

Kai

Hi Kai,

Well, Cell.GetStyle() and Cell.SetStyle() method consume less momory than Cell.Style property.

Well, in the lastest version, we add all the important Row / Rows and Column / Columns members to Cells class and removing the Row(s) / Column(s) types. You may use MaxRow, MaxDataRow, MaxDataRowInColumn and MaxColumn, MaxDataColumn properties for you need. Moreover, you may utilize Cells.ApplyRowStyle() and Cells.ApplyColumnStyle() methods for your apply some formattings to the whole row / column. In the newer version, we add a new method Cells.ApplyStyle() to apply style to the whole worksheet cells which are initiated.
And in the new version, you may get the style for the cell using Cell.GetStyle() method. You should create a style object(s), set its attributes for your desired formattings, and apply this style to a cell using Cell.SetStyle(styleobject), to worksheet cells using Cells.ApplyStyle(styleobject, styleflag), to a row using Cells.ApplyRowStyle(), to a column using Cells.ApplyColumnStyle() and to modify an existing style object using Style.Update() methods.
Thank you.

Amjad,

thanks for the explanation. Now a developer of mine has found another issue:

Copying style of smart tags does not work anymore

I’d like to bring him in to this discussion. Can you “unprivate” this topic, so that he may join?

Thanks

Kai

Hi Kai,

I have unchecked the private post tag.

Could you give us some more details and post a sample code with template file here to reproduce the issue. We will check it soon.

Thank you.

Amjad,

thanks for this. We were able to work around any issues. However, now I have a new one: When I open the attached Envelope.xls and copy a couple sheets into it, save it and then open it in Excel. I get an error message that a named range may not be named as an internal range (or anything like it). It flags the print title (german Drucktitel) to be used and I should give it a new name.

Note, Envelope.xls is the original Excel Workbook. 011 0425_20080229_Envelope.xls is one produced as such

- Opened Envelope.xls in Aspose.Cells 4.4.1.9
- Saved using Aspose.Cells (to database)
- In a later stage opened in Aspose.Cells (out of database)
- Sheets copied to the empty sheets within
- Saved using Aspose.Cells

Please advise. This is starting to kill us. With every hotfix release we stumble over new issues.

Thanks

Kai

Hi Kai,

I can open this 011 0425_20080229_Envelope.xls without any problem. As I know, this may be a language or region problem. You can try following code before saving the file:

workbook.Language = CountryCode.Germany;

workbook.Region = CountryCode.Germany;

workbook.Save(...);

Thanks, however how can I do this in a language independant manner? Is there anything I need to tweak on the source file? I can’t control the language settings on the users’ machines.

We will check more on this issue.

Based on our experience, English or Chinese MS Excel can handle Germany Excel file well but it seems that German MS Excel doesn't handle English Excel file well.

Hi Laurence,

thanks for the feedback. However I remember that we were once struggeling with the very same issue. This was over a year ago, but I believe it had to do with the very same Workbook (or at least a predecessor version of it).

Thanks

Kai

Yes, that's the same issue and I think you have solved it with this method.