Question

In: Computer Science

Hi! How I can convert from xml file to xlsx(excel ) sheet using Aspose.Cells, in C#...

Hi!

How I can convert from xml file to xlsx(excel ) sheet using Aspose.Cells, in C#

I Try with this code but I need loop , so  every element is one row with elements id (name )in column 1, and texten in column 2.

Workbook wb = new workbook();

worksheet ws = wb.worksheets[0];

ws.Cells[0,0].putValue("name");

wb.Save(path, "xml_to_exce.xlsxl");

Thanks!

Solutions

Expert Solution

Please find the code below let me know if you have any queries.

using System;
using System.Data;
using System.IO;
using Aspose.Cells;

namespace Assignment1
{
    class Program
    {
        static void Main(string[] args)
        {
            // Read XML file into DataSet Object
            // Note 
            DataSet ds = new DataSet();
            FileStream fs = new FileStream("XmlFilePath", FileMode.Open, FileAccess.Read);
            StreamReader reader = new StreamReader(fs);
            ds.ReadXml(reader);
            fs.Close();

            // Get the data into DataTable Variable
            DataTable dt = ds.Tables[0];

            // Load Aspose License
            Aspose.Cells.License li = new Aspose.Cells.License();
            li.SetLicense("Aspose_License_path"); //Cracking Certificate

            // Create New Work book and load data into workbook by looping over
            // DataTable Rows and Columns
            Workbook workbook = new Workbook();
            Worksheet worksheet = workbook.Worksheets[0];
            Cells cells = worksheet.Cells;

            int Colnum = dt.Columns.Count;
            int Rownum = dt.Rows.Count;

            for(int i=0; i<Colnum; i++)
            {
                cells[0, i].PutValue(dt.Columns[i].ColumnName);
            }

            for(int i=0; i < Rownum; i++)
            {
                for(int j = 0; j<Colnum; j++)
                {
                    cells[1 + i, j].PutValue(dt.Rows[i][j].ToString());
                }
            }
            //Save Workbook 
            workbook.Save("workbook_filepath");

        }
    }
}

Related Solutions

hello, i need to find chi square using statsgraphic. how can i upload the excel file...
hello, i need to find chi square using statsgraphic. how can i upload the excel file here. plz help....im on my last resort here. thank you.
Hi there, for this question. I found the answer in excel sheet to be negative. is...
Hi there, for this question. I found the answer in excel sheet to be negative. is ther something wrong with my calculation: Using the approach covered in your textbook calculate the geometric average annual rate of return over five years given the following annual rates, year 1 = 5.10%, year 2 = 4.95%, year 3 = 4.83%, year 4 = 4.75% and year 5 = 4.70% . What is the arithmetic average? Explain the difference. (Rates as a percentage accurate...
Hi i need a c++ program that can convert charactor into numbers pseodocode user input their...
Hi i need a c++ program that can convert charactor into numbers pseodocode user input their name for example john every single charactor should have a value so it return correct result eg: j=2, o=1, h=7,n=2 and display these numbers if you may need any question to ask me, i will be very happy to answer them. Thanks! example project close but not accurate #include #include #include #include #include #include #include #include #define INPUT_SIZE 8 using namespace std; // Function...
Hi i need a c++ program that can convert charactor into numbers pseodocode user input their...
Hi i need a c++ program that can convert charactor into numbers pseodocode user input their name for example john every single charactor should have a value so it return correct result eg: j=2, o=1, h=7,n=2 and display these numbers if you may need any question to ask me, i will be very happy to answer them. Thanks! example project close but not accurate #include<iostream> #include<string> #include<exception> #include <cstdlib> #include<stdio.h> #include<map> #include <cctype> #include<Windows.h> #define INPUT_SIZE 8 using namespace std;...
Hi, I can't figure out this question in excel, can someone please show me the excel...
Hi, I can't figure out this question in excel, can someone please show me the excel formulas to input in order to solve for part A and B please!!!! The following table contains closing monthly stock prices for Oracle Corporation (ORCL), Microsoft Corporation (MSFT), and NVidia (NVDA) for the first half of 2017. Ticker 6/30/2017 5/31/2017 4/30/2017 3/31/2017 2/28/2017 1/31/2017 ORCL 50.14 45.39 44.96 44.61 42.59 40.11 MSFT 68.93 69.84 68.46 65.86 63.98 64.65 NVDA 144.56 144.35 104.3 108.93 101.48...
I have an excel file imported into canopy (python) using import pandas as pd. The excel...
I have an excel file imported into canopy (python) using import pandas as pd. The excel file has headers titled: datetime created_at PM25 temperatureF dewpointF    humidityPCNT windMPH    wind_speedMPH wind_gustsMPH pressureIN precipIN these column headers all have thousands of data numbers under them. How could i find the average of all of the numbers in each column and plot them on 1 graph (line graph or scatter plot) Thank you.(please comment out your code)
1 Start Excel. Download and open the file named exploring_ecap_grader_a1.xlsx. 2 On the DC worksheet, select...
1 Start Excel. Download and open the file named exploring_ecap_grader_a1.xlsx. 2 On the DC worksheet, select the range A4:G4, wrap the text, apply Center alignment, and apply Blue, Accent 5, Lighter 60% fill color. 3 On the DC worksheet, merge and center the title in the range A1:G1. Apply Accent5 cell style and bold to the title. 4 On the DC worksheet, change the width of column A to 34. 5 On the DC worksheet, select the range C5:F10 and...
Hi, (C programming) I am looking to write a program that will encrypt a text file...
Hi, (C programming) I am looking to write a program that will encrypt a text file automatically once program has opened, and have the option to decrypt it in a menu in my program. I have multiple text files that I need to encrypt, and would like if the program could encrypt all of them at once. I would also only like to decrypt the a text file once the name has been entered into a scanf function.
Hello! I need to present my xml file on the Windows form application I tried but...
Hello! I need to present my xml file on the Windows form application I tried but it dosent work at button 2, I cann't show Xml_file. What is problem here please? have you any suggest or solution . Here is my form code! namespace MyFirstWindos { public partial class Form1 : Form { const string XML1 = "path"; const string XML2 = "Path"; const string ResultFile = "Path"; public Form1() { InitializeComponent(); } private void Run(object sender, EventArgs e)//run button...
c# Create a console application that protects an XML file, such as the following example. Note...
c# Create a console application that protects an XML file, such as the following example. Note that the customer's credit card number and password are currently stored in clear text. The credit card must be encrypted so that it can be decrypted and used later, and the password must be salted and hashed: <?xml version="1.0" encoding="utf-8" ?> <customers> <customer> <name>Bob Smith</name> <creditcard>1234-5678-9012-3456</creditcard> <password>Pa$$w0rd</password> </customer> </customers>
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT