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 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 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 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...
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...
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>
1. Create one XML data file and one DTD file for the entire data set (using...
1. Create one XML data file and one DTD file for the entire data set (using a subset of SQL assignment – see below). [Use of ID and IDREF are not required.] 2. Write and execute XML statements for the following two queries: Q1. Find the name of an employee who lives in Lincoln and works in Omaha. Q2. Find salaries of employees who live in the same cities as the companies for which they work. [You can replace one...
Hi, I am using excel and auditing cash on the company. The instructor say, " Vouch...
Hi, I am using excel and auditing cash on the company. The instructor say, " Vouch outstanding checks on the reconciliation to checks cleared in the next period." What does this mean? I know I will have to go to bank reconciliation, but I don't know what to do after that. Would you please help me? Thank you.
C++ Assignment Hi, I need to create a program that: 1.Reads a source file (.txt) with...
C++ Assignment Hi, I need to create a program that: 1.Reads a source file (.txt) with following information: 1,2,3,4,5 red,blue,green,yellow,orange left, right,front, back 2. After having program read the .txt file, output the above information in categories of Symbol, Token Type, and Count : Example: Symbol---Token Type (data type)----Count (how many times symbol appeared in .txt file) =========================================================================== 1 ----digit ----1 2 ----digit ----1 red ----color ----1 blue ----color ----1 left ----direction ----1 right ----direction    ----1
C++ Assignment Hi, I need to create a program that: 1.Reads a source file (.txt) with...
C++ Assignment Hi, I need to create a program that: 1.Reads a source file (.txt) with following information: 1,2,3,4,5 red,blue,green,yellow,orange left, right,front, back 2. After having program read the .txt file, output the above information in categories of Symbol, Token Type, and Count : Example: Symbol---Token Type (data type)----Count (how many times symbol appeared in .txt file) =========================================================================== 1 ----digit ----1 2 ----digit ----1 red ----color ----1 blue ----color ----1 left ----direction ----1 right ----direction    ----1
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT