Free Support Forum - aspose.com

Upload document, Excel to pdf convert error

Hi,
We are using Aspose.Excel18.10 version. We are using following code block in Test Project,

API.Global.sheetReplace(wb, “<REV_NO>”, REV_NO);

public static void sheetReplace(Workbook workbook, string sFind, string sReplace)
{
string finding = sFind;

        foreach (Worksheet sheet in workbook.Worksheets)
        {
            sheet.Replace(finding, sReplace);

            for (int j = 0; j < 3; j++)
            {

                if (sheet.PageSetup.GetHeader(j) != null)

                    sheet.PageSetup.SetHeader(j, sheet.PageSetup.GetHeader(j).Replace(finding, sReplace));

                if (sheet.PageSetup.GetFooter(j) != null)

                    sheet.PageSetup.SetFooter(j, sheet.PageSetup.GetFooter(j).Replace(finding, sReplace));

            }

        }

        foreach (Worksheet sheet in workbook.Worksheets)
        {

            sheet.Replace(sFind, sReplace);
            sFind = sFind.Replace("<", "&lt;");
            sFind = sFind.Replace(">", "&gt;");

            
            foreach (Aspose.Cells.Drawing.TextBox mytextbox in sheet.TextBoxes)
            {


                if (mytextbox.HtmlText != null)
                {
                    if (mytextbox.HtmlText.IndexOf(sFind) >= 0) mytextbox.HtmlText = mytextbox.HtmlText.Replace(sFind, sReplace);
                }
            }
        }
    }

I attach my error message and the original document WordToPdfError.zip (151.7 KB). Thanks

@srmbimser,

Thanks for your query.

I have tried to reproduce this issue using dummy value of REV_NO but could not observe any problem. Could you please suggest some value of REV_NO which causes this error? I used following call with latest version Aspose.Cells for .NET 18.10.x and no issue is observed.

Workbook wb = new Workbook(@"KYS.FR.082_1.xls");
SheetReplace(wb, "< REV_NO >", "REV_NO");

Hi,
we use the code above.
But html replicates itself while replacing text content.

Before

<DOC_KODU>
<REV_NO>

After

DOC_KODU
DOC_KODU
<REV_NO><REV_NO>

Thanks

foreach (Worksheet sheet in workbook.Worksheets)
{

        sheet.Replace(sFind, sReplace);
        sFind = sFind.Replace("<", "&lt;");
        sFind = sFind.Replace(">", "&gt;");

        
        foreach (Aspose.Cells.Drawing.TextBox mytextbox in sheet.TextBoxes)
        {


            if (mytextbox.HtmlText != null)
            {
                if (mytextbox.HtmlText.IndexOf(sFind) >= 0) mytextbox.HtmlText = mytextbox.HtmlText.Replace(sFind, sReplace);
            }
        }
    }

@srmbimser,

Please share a complete console or form based application (runnable solution) with us for our testing. We will reproduce the problem and provide our feedback after analysis.

Our Test Project:
http://dm.bimser.com.tr/eba.net/Default.aspx?turl=X-6JabCExUa8FpsN0new5Q

@srmbimser,

We have been able to reproduce following exception: Aspose.Cells.CellsException: ‘Object reference not set to an instance of an object.’ But the screenshot shared by you shows ArgumentException on your end. Could you please try latest version Aspose.Cells for .NET 18.10.7 and let us know your feedback.

Aspose.Cells18.10.7 For .Net4.0.Zip (4.7 MB)
Aspose.Cells18.10.7 For .Net2_AuthenticodeSigned.Zip (4.7 MB)

We tested latest version Aspose.Cells for .NET 18.10.7 and Aspose.Cells.CellsException: ‘Object reference not set to an instance of an object.’ error was continue.

@srmbimser,

We were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSNET-46449 - Exception raised while saving Excel file to PDF

@srmbimser,

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

Hi,
Is the new version available?
Thanks.

@srmbimser,

New version Aspose.Cells for .NET 18.11.0 contains fix for the issue under Id: CELLSNET-46449 for the following test project:

You may please download the latest version from this link or Nuget and provide the feedback.

Hi,
The problem still continues. The data is being multiplexed during replace.
I added a screenshot of the error.capture.png (28.9 KB)

There is also another problem with the attached zip file.
http://dm.bimser.com.tr/eba.net/Default.aspx?turl=xcRMrTAgOkqbOhLc30VD5g

at System.String.Substring(Int32 startIndex, Int32 length)
at .(String , TextAlignmentType , FontSetting , )
at .(FontSettingCollection )
at Aspose.Cells.Drawing.Shape.get_HtmlText()
at TestProject.Program.sheetReplace(Workbook workbook, String sFind, String sReplace) in C:\Users\ysarikaya\Desktop\QDMS\AsposeTestProject\TestProject\Program.cs:line 73
at TestProject.Program.Main(String[] args) in C:\Users\ysarikaya\Desktop\QDMS\AsposeTestProject\TestProject\Program.cs:line 27

Thanks

@srmbimser,

Thanks for your feedback.

I have checked the file “text.xlsx” (24KB) which was earlier provided and attached with the logged ticket. With that file exception “Object reference not set to an instance of an object” was raised which is resolved with the latest version Aspose.Cells for .NET 18.11.0.

Here in the last post you have shared a different file “test.xls” (148KB) which is raising a different exception. Hence we were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSNET-46460 - Exception "Index and length must refer to a location within the string" while accessing TextBox.HtmlText from the XLS

Hi,
Thank you for your return.

In the “test.xlsx” document, although “Object reference not set to an instance of an object” error is corrected, data continues to multiplex.capture.png (28.9 KB)

The issue that is more critical than the other error is for us to improve this problem.

@srmbimser,

Could you please explain the problem little more and share a file as expected output, for our analysis.

htmltextReplaceError.zip (9.5 MB)

Hi,

When I want to replace the value “<DOC_KODU>” in the document with “ys”, it multiplies the data in the form of
“ys
ys
ys
ys”.

Thanks

@srmbimser,

We were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSNET-46462 - Text repeated while replacing tag with text

@srmbimser,

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

Hi,
Is there any improvement.
Thanks.