Click here to Skip to main content
15,889,403 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am using this Code to add data to row and column in closed xml ,how to use this in open xml

C#
foreach (var header in dynamicHeaderList)
           {
               ws.Cell(rowID, column).Value = header;
               ws.Cell(rowID, column).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Center;
               ws.Cell(rowID, column).Style.Fill.BackgroundColor = XLColor.FromArgb(204, 255, 204);
               ws.Cell(rowID, column).Style.Font.Bold = true;
               ws.Cell(rowID, column).Style.Border.OutsideBorder = XLBorderStyleValues.Hair;
               column++;
           }
Posted

1 solution

I'm not sure how you want to use openxml here.

To create a table you will need to use the Open xml SDK. Working with WordprocessingML tables (Open XML SDK)[^] provides and example where a table is created from an xml.

On the database side, Sql server OpenXml provides a rowset view over an XML document so you can parse the xml faster and do stuff with the records.

For example, you can read an xml and insert into database.
Instead of looping row by row and inserting records one by one, you can bulk insert 1000 of records reducing as many number of calls to the database.

You can also run select queries over OpenXml.

To know more about it, go through OPENXML (Transact-SQL)[^].
 
Share this answer
 
Comments
Nawab Ahmad 5-Jan-16 22:31pm    
Because i am getting 2 Lakhs recors

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900