Free Support Forum - aspose.com

SSRS Report export to Aspose.Words (HTML) throws strange error possibly due to regex function calls

When exporting a report to to Aspose.Words->HTML format, we receive the above error dialog, and the renderer does not successfully export to HTML.

"An error occurred during local report processing:
Length cannot be zero.
Parameter name: length"

I assume the error is being thrown because of a custom function that I have written called "CleanMsTable". This function takes the value of a field (HTML markup that is stored in our TFS database), and tries to strip out some of the extraneous markup for display in Word or HTML. The error does not seem related to the custom function that I have written which is just a few calls to System.Text.RegularExpressions.Regex.Replace(..)

This is the code for the function:


Public Function CleanMsTable(ByVal s As String) As String

s = System.Text.RegularExpressions.Regex.Replace(s, "class=MsoNormalTable", "")
s = System.Text.RegularExpressions.Regex.Replace(s, "class=MsoNormal", "")
s = System.Text.RegularExpressions.Regex.Replace(s, "]*>", "")
s = System.Text.RegularExpressions.Regex.Replace(s, "", "")
s = System.Text.RegularExpressions.Regex.Replace(s, "]*>", "")
s = System.Text.RegularExpressions.Regex.Replace(s, "style=""([^""]*)""([^>]*)", "")
Return s
End Function

This is just an example of the kinds of stuff we want to strip out. We ultimately would like to strip the markup down to barebones HTML table format, with only enough style to put grid-lines on the table. However, I've presented just limited code above since we're trying to narrow down the problem.

One thing to consider here, is that the backing datatype for the field that we are parsing is of sql type "ntext". Are there limitations when dealing with text that comes out of this type of field? I have read that this type is deprecated in SQL Server, but unfortunately, the type is being used in a TFS database, so we are sort of stuck with it!

Basic system information: Windows XP using MS Visual Studio 2008, connecting to the MS TFS database on a SQL Server 2008 server. Also, I have attached the RDL (and it's corresponding *.rdl.data file) in a zip file attached to this post. Please let me know what further information you might need.

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. Have you tried exporting the same report without your find/replace methods? Does it throw the same error?

Maybe find/replace breaks HTML and that is why the problem occurs. You can try saving HTML string after processing it using your method and check whether it is ok.

Best regards.

Hi Alexey,

To answer your first question, yes I have tried exporting the same report without calling that function on that field, and I get the exact same error. So, I am positive that the problem is not caused by my function (those are very basic regex replace calls).

Also, I developed the function in a separate VB console program and then called the program on the exact same string, and it processed the string without a problem. I then took the output of that processing and dumped it into an HTML file, and it opened in IE6 exactly as desired.

Are you able to reproduce the error using the RDL/.DATA file that I submitted? I am attaching the RDL/.rdl.data file with the custom function commented out for your perusal.

Hi Rustam,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. Your request has been logged in our defect database. The developer, who is responsible for Aspose.Words for Reporting Services will answer you shortly.

Best regards.

Hi Alexey,

I also deployed this to my local SSRS server, and was able to get a more detailed .NET stacktrace out of it. Please see the attached screenshot of the .NET error.

Hi Alexey,

I've run a few tests on my end to determine what type (or length) of input may be causing the problem.

This is the basic rundown of my tests:

1. I created several HTML files with basic tables of varying column and row count.

2. I then opened each of the files in IE6 and copied the screen contents into the TFS work item text box where the offending data is being inputted.

3. I then re-ran the report with the new data (the same report I sent to you guys). I then recorded the results of the HTML export using the Aspose component in the table below

The most baffling thing about this problem is that a 2 column table failed at a certain total character count, but a 3 column table with almost exactly the same total character count did not fail (under the test below). It would also appear that results vary significantly depending on the nature of the HTML.

All of the test data below was using extremely simple HTML tables (ie. nothing more than table>tr>td tags, with no style).

In addition to this, it appears that even when it does succeed without error (with very simple HTML tables), the format of the table breaks easily across multiple pages in the report...

Hope this helps...

test file Line Breaks Total Char count # of HTML table columns # of HTML table rows Export To Aspose HTML Table Structure
nobr1k.html no 1000 2 100 success last couple rows degrade to just in-line display
nobr2k.html no 2000 2 200 success latter half of table degrades to in-line display
nobr3k.html no 3000 2 300 error n/a
nobr4k.html no 4000 2 400 error n/a
nobr1k.html no 1000 3 100 success last couple rows degrade to just in-line display
nobr2k.html no 2000 3 200 success latter half of table degrades to in-line display
nobr3k.html no 3000 3 300 success latter 2/3 of table degrades to in-line display, also 3 blank pages show up in between the first part and second part of tables
nobr4k.html no 4000 3 400 success latter 2/3 of table degrades to in-line display, also 3 blank pages show up in between the first part and second part of tables
nobr5k.html no 5000 3 500 success latter 2/3 of table degrades to in-line display, also 3 blank pages show up in between the first part and second part of tables
Repeat execution of first 4 tests
nobr1k.html no 1000 2 100 success last couple rows degrade to just in-line display
nobr2k.html no 2000 2 200 success latter half of table degrades to in-line display
nobr3k.html no 3000 2 300 error n/a
nobr4k.html no 4000 2 400 error n/a

Hi Rustam,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. Could you also attach your test HTML files, which cause the problem? Aspose.Words for Reporting Services internally uses Aspose.Words for .NET. So I would like to try to reproduce the problem using Aspose.Words for .NET.

Best regards.

Hi Alexey,

I've attached a zip file of 4 of the files (the 2 column HTML tables). It's the second two that are causing the error (nobr3.html, and nobr4.html).

Were you able to reproduce the error with the original *.rdl and *.rdl.data files?

thanks
R

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. I cannot reproduce the problem with Aspose.Words for .NET. So the problem is somewhere in Aspose.Words for Reporting Services. The developer, who is responsible for Aspsoe.Words for Reporting Services will take a look at this issue shortly. Please expect a reply within a week.

Best regards.

Hi Alexey, Do you know if there's been any progress on this issue? We are trying to wrap up an evaluation of this component for use in our project, and we're specifically interested in licensing the product for the HTML rendering feature...

thanks

Rustam

Hi Rustam,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

My apologizes for delay. The issue will be resolved in 2-3 days. We will let you know once it is fixed.

Best regards.

Hi Alexey,

Is there any update on this fix?

thanks
R

Hi Alexey -

We are waiting on this fix so we can validate it for purchase. Any word on a reasonable ETA?

Thanks,

Allen