I want to convert html to xls format without Microsoft Office

Asked 1 months ago, Updated 1 months ago, 5 views

I am using .NET Framework 3.5.

The target program uses Microsoft.Interop.Excel.dll to convert the Html format file to an Xls format file, but the target customer environment still has Excel installed, but it may be restricted or the dll does not call Excel.
It behaves as if Excel is not installed.

Currently, the above investigation is difficult, so we are investigating how to convert Html to xls without using the Excel function installed in the operating environment using the above dll. Do you know any samples?
It is possible to do the following without using a program using Excel, but I would like to use a third-party program such as NPOI to print xls without Excel installed.Until html can be generated, it can be verified in the target customer environment.

If you have a sample code, could you please let me know?It doesn't have to be NPOI.


2022-09-30 13:48

2 Answers

For a fee, Aspose.Cells for .NET can be converted from html to .xls.I don't know how complicated the html is, but I think you should try it.

using System.IO;

using Aspose.Cells;
using System;

    public class OpeningHTMLFile
        public static void Run()
            // ExStart—1
            // The path to the documents directory.
            string dataDir=RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

            US>//#string filePath=dataDir+"Book1.html";

            // Instantiate LoadOptions specified by the LoadFormat.
            Html LoadOptions loadOptions = new Html LoadOptions (LoadFormat.Html);

            // Create a Workbook object and opening the file from its path
            Workbook wb = new Workbook (filePath, loadOptions);
            // Save the MHT file
            // ExEnd:1

.NET Framework 3.5 is also supported.

2022-09-30 13:48

You can try this product by converting html to xls.
There is a free version.

Here's the code.

using Spire.Xls;

namespace HTML_to_Excel
    class program
        static void Main (string[]args)
            // Load the sample document 
            Workbook = new Workbook();

            // AutoFitrows
            Worksheet sheet=workbook.Works[0];

            // Save the document to file
            workbook.SaveToFile("Result.xlsx", FileFormat.Version 2010);

2022-09-30 13:48

If you have any answers or tips

© 2022 OneMinuteCode. All rights reserved.