Is it possible to import an html string into the Aspose’s excel worksheet so it is subsequently saved in the excel file as a workseet?
HTML import feature is not support in Aspose.Excel now. We will implement this feature in the future. It will take about several months to implement this feature.
That’s funny, that is exactly what you said in one of the threads on the topic posted two years ago in 2003.
Can you suggest a way to import text into Aspose’s worksheet and save it in the excel file.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
We did plan to implement html import/export feature before but we postponed this work for we found it’s too complex and we had many other urgent feature requests on hand.
Now we implement xls2asposepdfxml feature and are working on xls2spreadsheetml feature. When the xls2spreadsheetml is completed, we will start to do xls2html and html2xls feature. So html import/export feature will started in about one or two weeks.
Now to import text into Aspose’s worksheet, you can try the following:
1. Convert the file to CSV file and use Excel.OpenCSV method to import it.
2. Process the txt file by your own code and use Cell.PutValue(string) method to put strings to cells in worksheet.
I need to have one regular worksheet with the cells (table) and the other a worksheet with the text, such as csv. Will I be able to do it if I open the Excel with OpenCSV, Excel.OpenCSV ?
I don’t clearly understand your need. Could you elaborate it?
If you use Excel.Open method to open a csv file, Aspose.Excel will import it to Aspose.Excel object model. You can save the whole file as Excel file or as CSV file. But you cannot save a worksheet as Excel file and another worksheet as CSV file now.
Sorry for the confusion. I have to create an excel object with two worksheets; one worksheet consisting a table another working consisting the csv. I would import a DataTable into one worksheet, and import csv (I am not sure how to do it) into the other worksheet. Then, I need to save the excel into an excel file. So, the new file has two worksheets; one with the table and the other with the csv.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
1. You can use Excel.OpenCSV to import a csv file to the first worksheet.
2. You can use Cells.ImportDataTable to import a DataTable to another workshee.
3. Then you can save the result into an Excel file.
The OpenCSV call confuses me. I have a design file that I have to use. The design file is for the macros. So, I can’t open csv. Yet, once I open the excel with the design file I need to add one worksheet and import a table and another worksheet and import cvs. The cvs is represented as a string and not as a file.<?xml:namespace prefix = o ns = “urn:schemas-microsoft-com:office:office” /><o:p></o:p>
If your csv is a string and not a file, you can try this:
//inputCSV is the csv string
string rows = inputCSV.Split('\n');
for(int i = 0; i < rows.Length; i ++)
cells.ImportArray(rows.Split(','), i, 0, false);
This is to inform you that Aspose.Excel is discontinued and replaced with Aspose.Cells that has all the features of Aspose.Excel along with the support for the latest features in MS Excel. You can import HTML file into Excel file by setting a lot of properties before import. It provides you control over the HTML loading operation and performs multiple tasks before importing HTML into an Excel file. Here is a simple example that can be used to import HTML into an Excel file using Aspose.Cells.
// Sample Html containing redundant spaces after <br> tag string html = "<html> <body> <table> <tr> <td> <br> This is sample data <br> This is sample data<br> This is sample data</td> </tr> </table> </body> </html>"; // Convert Html to byte array byte byteArray = System.Text.Encoding.UTF8.GetBytes(html); // Set Html load options and keep precision true HTMLLoadOptions loadOptions = new Aspose.Cells.HTMLLoadOptions(LoadFormat.Html); loadOptions.DeleteRedundantSpaces = true; // Convert byte array into stream MemoryStream stream = new MemoryStream(byteArray); // Create workbook from stream with Html load options Workbook workbook = new Workbook(stream, loadOptions); // Access first worksheet Worksheet sheet = workbook.Worksheets; // Auto fit the sheet columns sheet.AutoFitColumns(); dataDir = dataDir + "DeleteRedundantSpaces_out.xlsx"; // Save the workbook workbook.Save(dataDir, SaveFormat.Xlsx);
The latest free trial version of this product can be downloaded here:
Aspose.Cells for .NET (Latest Version)
You can test different features of this new product by downloading an executable solution here.