We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Hide Columns feature in a Excel and saving the excel into document throws the "Index was outside the bounds of the array" error

We are currently using Aspose.Word (version 5.2.2.0) to view the HTML preview of the Excel spread sheet. When we hide the rows of the Excel (MS Office 2007) and then saving the Excel into Aspose.Word Document and save the Aspose Document using the save method (document.Save(doc, saveformat.HTML):wink: it works fine and the hiden rows are not visible in the Html preview. But if we use the same excel and instead of hide rows we use hide columns (any column), the
document Save method throws and error saying:

Index was outside the bounds of the array. at ᘶ.ᛶ.᜔() 
at ᘶ.ᛶ..ctor(Table tableNode, Boolean resolveInheritedBorders, Boolean populateEmptyPadBorders) 
at ᒀ.ᑿ.VisitTableStart(Table table) 
at Aspose.Words.Tables.Table.Accept(DocumentVisitor visitor) 
at Aspose.Words.CompositeNode.࠿(DocumentVisitor ࡀ) 
at Aspose.Words.Body.Accept(DocumentVisitor visitor) 

Any simple Word Excel file could be used with the Hide Columns feature. Is this truely an glitch in Aspose.Word? Could you please help us find a solution to this issue?
Also, we tried to look at it differently. Initially, when we are saving the Excel to Document thought may be we could delete all the columns that are hidden in the Excel. We looked at Aspose.Cells (properties and methods of workbook) and could not figure out a way to retrieve the columns that are hidden. Is this a possiblity?

Hi
Thanks for your inquiry. Are you using Excel2Word demo for conversion your xls files? Or you created your own converter? Anyway please attach sample documents. I will investigate the problem and provide you more information.
Best regards.

Hi Alexey,
Thank you for the reply. No we are not using the Excel2Word Demo for conversion. I have attached a sample xls document where the column 3 is hidden. I have included a code snippet document which will outline our flow. Please refer this. If you need more information please do let me know.
Best Regards,
Lakshmi

Hi
Thank you for additional information. So you are using class from excel2Word demo to convert Excel workbook to Doc. I tried to reproduce the problem on my side. But it seems that all works fine. One difference I use the latest version of Aspose.Words and Aspose.Cells. Also there were few modifications in the ConverterXls2Doc class. Please find the attachment.
So please try using the latest version of Aspose.Words, Aspose.Cells and converter class.
Best regards.

Hi Alexey,
Thank you for the prompt reply. I did down load the Aspose.Words v5.2.1.0 and Aspose.Cells v4.5.1.0 and used the attached ConverterXls2Doc but ran into build errors. Could you please let me know what version of Words and Cells work with this converter. I have attached the errors file so you will get an idea.
Best Regards,
Lakshmi

Hi
Thanks for your inquiry. As I told you earlier I use the latest versions.
Aspose.Words 5.3.0
https://releases.aspose.com/words/net
Aspose.Cells 4.5.1
https://releases.aspose.com/cells/net/
But it seems that the problem occurs because you are using VS 2008 and VS2008 recognize inconsistency in XML comments as errors. Please try using the attached class (I corrected comments)
Best regards.

Thank you for the info.
Actually we are using the vs2005. Anyways, everything appears to compiling and no errors while viewing the HTML Preview. But the problem now is we see even the HIDDEN COLUMNS or the HIDDEN ROWS too in the HTML preview. I really appreciate if you could look into this further and assist me.
Best Regards,
Lakshmi

Hi
Thanks for your inquiry. You can try to remove hidden columns and rows from the excel workbook before conversion.
Best regards.

Thank you. I am new to this. Can you please point me where i can find some sample code which does that. Because that was my first (unsucessful, I must add) try but could not find any method and/or properties which will return me the hidden rows or columns and then delete them. I really appreciate your help regarding this.
Best Regards,
Lakshmi

Hi
Thanks for your inquiry. You can try using the following code to remove hidden columns:

Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook();
wb.Open(@"Test179\Test.xls");
foreach (Aspose.Cells.Worksheet sheet in wb.Worksheets)
{
    for (int colIdx = sheet.Cells.MaxColumn; colIdx >= 0; colIdx--)
    {
        // Remove columns with 0 width
        if (sheet.Cells.GetColumnWidth(colIdx) == 0)
        {
            sheet.Cells.DeleteColumn(colIdx);
        }
    }
}
wb.Save(@"Test179\out.xls", Aspose.Cells.FileFormatType.Excel2003);

The same technique could be used to remove hidden rows. Also you can contact with Aspose.Cells team in the corresponding forum to get more information.
Best regards.