Rendering an Excel file to PDF file format gives an exception "System.StackOverflowException" in .NET

Hi,
When the appended document is displayed on the system, it is encountered with the “System.StackOverflowException: ‘Exception of type’ System.StackOverflowException ‘was thrown.’” error.
I attached the original file and corrupted file. We are using Aspose.Cell 19.5 version. Thanks.
YG8636.zip (192.4 KB)

@srmbimser,
Please share the code snippet with us for our testing. We will reproduce the problem and provide our feedback after analysis.

The code snippet used

protected void btnConvert_Click(object sender, EventArgs e)
{

        API.AsposeLicence.SetAsposeLicence();
        sw.Start();
        string fileName = txtFileName.Text;

        extension = fileName.Substring(fileName.LastIndexOf('.'), fileName.Length - fileName.LastIndexOf('.'));

        if (extension == ".doc" || extension == ".docx")
        {
            Aspose.Words.Document doc = new Aspose.Words.Document(this.UploadDirectory + fileName);

            foreach (Aspose.Words.Tables.Table table in doc.GetChildNodes(Aspose.Words.NodeType.Table, true))
            {
                bool isHF = false;

                foreach (Aspose.Words.HeaderFooter hf in doc.GetChildNodes(Aspose.Words.NodeType.HeaderFooter, true))
                {
                    foreach (Aspose.Words.Tables.Table table1 in hf.GetChildNodes(Aspose.Words.NodeType.Table, true))
                    {
                        if (table1 == table)
                        {
                            isHF = true;
                            break;
                        }
                    }
                    if (isHF) break;
                }
                if (!isHF)
                    table.TextWrapping = Aspose.Words.Tables.TextWrapping.None;
            }


            if (txtRepTag.Text != "" && txtRepValue.Text != "")
            {
                string value = "";
                foreach (string item in txtRepValue.Text.Split('$'))
                {
                    value += item + Aspose.Words.ControlChar.LineBreak;
                }
                API.Global.ReplaceWithEvaluator(doc, txtRepTag.Text, value, true);
            }
            doc.AcceptAllRevisions();
            #region Writing Log
            API.Global.WriteLog("-----------------------------------");
            API.Global.WriteLog(string.Format("Converting Started - {0}", sw.ElapsedMilliseconds));
            #endregion
            doc.Save(this.UploadDirectory + fileName.Substring(0, fileName.LastIndexOf('.')) + ".pdf", Aspose.Words.SaveFormat.Pdf);
        }

@srmbimser,
It seems that you have shared some wrong piece of code. Please share the code related to Aspose.Cells.

Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(this.UploadDirectory + fileName);
if (txtRepTag.Text != “” && txtRepValue.Text != “”)
{
string value = “”;
for (int i = 0; i < txtRepTag.Text.Split(’$’).Length; i++)
{
API.Global.sheetReplace(wb, “<” + txtRepTag.Text.Split(’$’)[i] + “>”, txtRepValue.Text.Split(’$’)[i]);
}

            }
            #region Writing Log
            API.Global.WriteLog("-----------------------------------");
            API.Global.WriteLog(string.Format("Converting Started - {0}", sw.ElapsedMilliseconds));
            #endregion


            Aspose.Cells.PdfSaveOptions opts = new Aspose.Cells.PdfSaveOptions();
            if (chkOnePage.Checked)
            {
                opts.OnePagePerSheet = true;
            }

            wb.Save(this.UploadDirectory + fileName.Substring(0, fileName.LastIndexOf('.')) + ".pdf", opts);

@srmbimser,
I have used below code and problem did not reproduce with latest version/fix. Could you please try again and let us know your feedback.

Workbook wb = new Workbook("ERM.D3_4_3.LIST.01_9.xlsx");
PdfSaveOptions opts = new PdfSaveOptions();
opts.OnePagePerSheet = true;
wb.Save("ERM.D3_4_3.LIST.01_9.pdf", opts);

Aspose.Cells19.5.3 For .Net4.0.Zip (4.9 MB)
Aspose.Cells19.5.3 For .Net2_AuthenticodeSigned.Zip (4.9 MB)

@srmbimser,

After further investigation, I was able to reproduce the issue as you mentioned by simply converting your template file to PDF file format. I found an exception “System.StackOverflowException” on rendering the Excel file to PDF file format:
e.g
Sample code:

Workbook workbook = new Workbook("ERM.D3_4_3.LIST.01_9.xlsx");
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
workbook.Save("out.pdf", pdfSaveOptions);

I have logged a ticket with an id “CELLSNET-46765” for your issue. We will look into it soon.

Once we have an update on it, we will let you know.

@srmbimser,
This is to inform you that we have fixed your issue (logged earlier as “CELLSNET-46765”) now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.

@srmbimser,

Please try our latest version/fix: Aspose.Cells for .NET v19.5.7 (attached).

Your issue should be fixed in it.

Let us know your feedback.
Aspose.Cells19.5.7 For .Net2_AuthenticodeSigned.Zip (4.9 MB)
Aspose.Cells19.5.7 For .Net4.0.Zip (4.9 MB)

The issues you have found earlier (filed as CELLSNET-46765) have been fixed in Aspose.Cells for .NET v19.6. This message was posted using BugNotificationTool from Downloads module by Amjad_Sahi