Hi,
On .NET 5 or 6 DocIO can't read html file when the Regional format is Thai (Thailand).
It will throw error System.ArgumentOutOfRangeException: 'Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'startIndex')'
public IActionResult CreateDocumentWord()
{
//Set Thailand culture
CultureInfo.CurrentCulture = new CultureInfo("th-TH");
FileStream fileStreamPath = new FileStream("Sample.html", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
//Opens an existing document from file system through constructor of WordDocument class
using (WordDocument document = new WordDocument(fileStreamPath, FormatType.Html))
{
MemoryStream stream = new MemoryStream();
document.Save(stream, FormatType.Docx);
//Closes the Word document
document.Close();
stream.Position = 0;
//Download Word document in the browser
return File(stream, "application/msword", "HTMLtoWord.docx");
}
}
We have
confirmed that the reported issue “ArgumentOutOfRangeException throws while opening HTML document when
current culture is Thailand” is a defect
and we have logged a defect report. We will include the fix for this defect in
our weekly NuGet release which is estimated to be available on end of November 2022.
The status of this bug can be tracked through the below link:
https://www.syncfusion.com/feedback/39146/argumentoutofrangeexception-throws-while-opening-html-document-when-current
Disclaimer: “Inclusion of this solution in the weekly release may change due to
other factors including but not limited to QA checks and works reprioritization.”
As promised earlier, we have included the fix
for the reported issue with “ArgumentOutOfRangeException
throws while opening HTML document when current culture is Thailand”
in our latest weekly NuGet release (v20.3.0.59).
Please use the below link to download our latest weekly NuGet:
https://www.nuget.org/packages/Syncfusion.DocIO.Net.Core/20.3.0.59
The status of this bug task can be tracked through the below link:
https://www.syncfusion.com/feedback/39146/argumentoutofrangeexception-throws-while-opening-html-document-when-current
Note: We will include this fix in our 2022 Volume 4
Main release which will be available in mid of December 2022.
This issue comes back again in 24.
Utarn, we tried to reproduce
the reported problem using the latest version (v24.2.4), but it works
properly on our end. For your reference, we have attached the sample
application which we used at our end to reproduce the reported problem and it
can be downloaded from the below attachment.
Can you please try our sample application at your end using your Word document?
If you are still facing the issue means, we suspect that the issue might be due
to the input Word document. So, kindly share the input Word Document to
reproduce the reported issue.
Note: If you have any confidential data in your input Word document,
please replace with some dummy data and provide us the same. We just need your
document to recreate the problem you face. So, once investigated the issue, we
will delete the document permanently from our side and do not share with
anyone.
If you are doing some other process in the
code, please modify the sample attached and share it as issue
reproducible sample. Thereby, we
will proceed further to replicate the same problem at our end and will provide
the more details at the earliest.