Office

Office 2016 Preview available

May 4, 2015 Microsoft, Office, Office 2016, Preview, Previews, Windows, Windows 10, Windows 7, Windows 8, Windows 8.1, Windows Phone No comments

Microsoft has released Office 2016 Preview

Download links

Obtain license key from: https://products.office.com/en-us/office-2016-preview#howToGet

Read more about features available from official blog: http://blogs.office.com/2015/05/04/office-2016-public-preview-now-available/

Write and Publish your blogs in Word 2013 – Office 2013

October 18, 2012 All, Help Links, KnowledgeBase, Microsoft, Office, Office 2013, Recommends, Tips & Tricks, Web 2 comments

Word 2013 in Office 2013 having a nice feature which will help us to write blog posts and publish to any blog provider such as wordpress, blogger etc.

Using the blog post template in Word 2013 ,you can easily write blog posts in your word and publish them to your blog.

Here is some screen shots that explains it from Office 2013 preview

image

Select Blog post template –> it will download the template from online repository for first time

 

image

Now it is the time to setup your account

image

You have the following choices Blogger, Sharepoint blog, WordPress, Typepad etc

image

 

If you have selected Blogger, you will see the below prompt asking for blogger credentials

image

or if WordPress specify the wordpress blog url and your account details

image

image

Now it is the time to specify the settings to upload images from the blog post you are creating

image

or your own server

image

 

Now click on OK and you will see and alert message confirming the setup.

If you have multiple blog account you can manage it using the blog account section

image

 

Now write your blog like a normal word document and format it and choose any of the publish option. You also have the option to specify the categories of your post.

 

image

Select the categories

image

 

Awesome isn’t it.. Hope that is helpful. Try it yourselves.

Office 2010–Service Pack 1 Released

July 1, 2011 All, General, Microsoft, Office, Office 2010, Share Point, Updates No comments

Microsoft has released the final version Service Pack 1 for Office 2010. It is a quite surprise since there was not been any BETA versions of Sp1 announced and testing has been done by a bunch of selected beta testers.

To get an overview of enhancements in Office 2010 Service Pack 1, please visit this knowledge base article

and Service Pack 1 for Visio 2010, Project 2010 and SharePoint Server, Designer & Foundation 2010 is also available for download via Microsoft Download Center

To quickly download Office 2010 Service Pack, please use the link given below.

Download : Microsoft Office 2010 SP1 x86

Download : Microsoft Office 2010 SP1 x64

and

Additional Downloads

Service Pack 1 for Microsoft Visio 2010 (KB2460061) 64-bit Edition 

Service Pack 1 for Microsoft Visio 2010 (KB2460061) 32-bit Edition

 

Service Pack 1 for Microsoft Project 2010 (KB2460052) 64-bit Edition

Service Pack 1 for Microsoft Project 2010 (KB2460052) 32-bit Edition

 

Service Pack 1 for Microsoft Office Web Apps 2010 (KB2460073)

Service Pack 1 for Microsoft Office Proofing Tools 2010 (KB2460053) 32-bit Edition

Service Pack 1 for Microsoft Office Proofing Tools 2010 (KB2460053) 64-bit Edition 

SharePoint Server 2010 – Sp1

Service Pack 1 for Microsoft SharePoint Server 2010 (KB2460045) 

Service Pack 1 for Microsoft SharePoint Designer 2010 (KB2460057) 64-bit Edition

Service Pack 1 for Microsoft SharePoint Designer 2010 (KB2460057) 32-bit Edition

Service Pack 1 for SharePoint Foundation 2010 (KB2460058)

Other Office Server 2010 Updates

Service Pack 1 for Microsoft FAST Search Server 2010 (KB2460039)

Service Pack 1 for Microsoft Search Server 2010 (KB2460070)

Service Pack 1 for Microsoft Groove Server 2010 (KB2460067)

Microsoft Office 2010 Filter Packs to Search Contents for Windows 7

October 8, 2010 All, Microsoft, Office, Office 2010, Windows 7 1 comment

Microsoft Filter Packs is a single point-of-distribution for Office IFilters. IFilters are components that allow search services to index content of specific file types, allowing user to search for content (i.e. text within the document) in those files. In other words, Office 2010 Filter Packs enhance the default search capabilities of Microsoft Search Services in SharePoint, SQL Server, Exchange Server and Windows Search used in Windows server or client platforms such as Windows 7 and Windows Server 2008 R2.

By installing Microsoft Office 2010 Filter Packs, the following IFilters will be installed, and system will have additional capability to search for content in the file types or extensions listed below:

* Legacy Office Filter (version 97-2003; .doc, .ppt, .xls)
* Metro Office Filter (version 2007 and 2010; .docx, .docm, .pptx, .pptm, .xlsx, .xlsm, .xlsb)
* Zip Filter (.zip)
* OneNote filter (.one)
* Visio Filter (.vdx, .vsd, .vss, .vst, .vdx, .vsx, .vtx)
* Publisher Filter
* Open Document Format Filter

Windows Search Services was previously known as Windows Indexing Services. The filter packs support Windows 7; Windows Server 2003 SP2; Windows Server 2008 R2; Windows Server 2008 SP2; Windows Vista SP1 ;Windows XP SP2; and Windows XP SP3. As it’s a filter, the Microsoft Filter Pack requires the Microsoft Search Service.

Download Microsoft Office 2010 Filter Packs from Microsoft Download Center or by using the following direct download links:

32-bit (x86): FilterPack32bit.exe
64-bit (x64):
FilterPack64bit.exe

source: mydigitallife.info

Open XML SDK 2.0

September 27, 2010 .NET, All, Microsoft, Microsoft SDKs, Office, Open XML No comments

Open XML SDK 2.0 for Microsoft Office

The Open XML Format SDK 2.0  is a superset of the Open XML SDK 1.0. In addition to the functionality provided by the Open XML SDK 1.0, it leverages.NET Language-Integrated Query (LINQ) and provides classes to construct and query the contents of parts within a package. You can use functional construction for composing documents, and LINQ queries for extracting information from documents.

The SDK is a collection of classes that let developers create and manipulate Open XML documents – documents that adhere to the Office Open XML File Formats Standard. Because the SDK provides an application program interface that lets developers manipulate Open XML documents directly, they can do so without the need for the Office client products themselves in both client and server operating environments.

Open XML SDK 2.0 for Microsoft Office offers a number of tools and resources to improve programmatic document processing thus making a task of the developer more efficient. The SDK also carries an interoperability improvements for open XML implementers as well as it is  designed to let Open XML developers build high performance client-side or server-side solutions that handle complex operations using only a small amount of program code.

Download Open XML SDK 2.0 for Microsoft Office.

MSDN Reference Link

Content Taken from  : Erika Ehrli’s – Blog in MSDN 

Some useful links from MSDN

Book chapter:

Book Excerpt: Chapter 22: Office Open XML Essentials

 

Code samples:

CG: Sample: Word 2007 Sample: Using Open XML to Improve Automation Performance in Word 2010 for Large Amounts of Data
Sample: 2007 Office Sample: Building a Server-Side Document Generation Solution Using the Open XML Object Model
Sample: 2007 Office Sample: Manipulating Office Open XML Format Files
Sample: 2007 Office Sample: Using the Office Open XML Formats to Support Electronic Health Records Portability and Health Industry Standards
CG: Sample: 2007 Office Sample: Introducing the Open XML Format External File Converter for Microsoft Office
CG: Sample: 2007 Office Sample: Creating Documents by Using the Open XML Format SDK 2.0
CG: Sample: 2007 Office Sample: Open XML File Formats Code Snippets for Visual Studio 2008 Using the Open XML SDK 2.0 for Microsoft Office

 

Columns:

OfficeTalk: Creating Form Letters in Word by Using Bookmarks and Office Open XML Files
OfficeTalk: Working with In-Memory Open XML Documents
OfficeTalk: Programmatically Update Multiple External Data Connections in Excel 2007 by Using Open XML

 

Downloads:

Download: SharePoint 2010 Presentation: Deep Dive into Open XML 2.0 and the Open XML SDK 2.0
Download: 2007 Office Presentations: Open XML Training Presentations
Download: 2007 Office System Document: Open XML Developer Map

 

Visual How-tos (how-to article + video + code sample):

Visual How To: Building Word 2007 Documents Using Office Open XML Formats
Visual How To: Embedding Documents in Word 2007 by Using the Open XML SDK 2.0 for Microsoft Office
Visual How To: Adding Images to Documents in Word 2007 by Using the Open XML SDK 2.0 for Microsoft Office
Visual How To: Generating Documents with Headers and Footers in Word 2007 by Using the Open XML SDK 2.0 for Microsoft Office
Visual How To: Merging Simple Content from Excel 2007 Workbooks and Worksheets by Using the Open XML SDK 2.0 for Microsoft Office
Visual How To: Merging PowerPoint 2007 Decks Together by Using the Open XML SDK 2.0 for Microsoft Office
Visual How To: Using the Open XML SDK 2.0 Classes Versus Using .Net XML Services
Visual How To: Retrieving Content from Different Parts: Explicit or Implicit Relationships in the Open XML SDK 2.0 for Microsoft Office
Visual How To: Searching for Content in Word 2007 Documents by Using the Open XML SDK 2.0 for Microsoft Office
Visual How To: Generating a Word 2007 Document by Using PowerTools for Open XML and Windows PowerShell
Visual How To: Creating a PowerPoint 2007 Presentation from a Folder of Images by Using the Open XML SDK 2.0 for Microsoft Office
Visual How-To: Using XSLT and Open XML to Create a Word 2007 Document
Visual How To: Using XSLT and Open XML to Create a Word 2007 Document
Visual How To: Displaying Open XML Spreadsheet Tables in the Browser Using Silverlight

 

Technical articles:

Creating Valid Open XML Documents by Using the Validation Tools in the Open XML Format SDK
Introducing the Office (2007) Open XML File Formats
Using the SharePoint Foundation 2010 Managed Client Object Model with the Open XML SDK 2.0
Accepting Revisions in Open XML Word-Processing Documents
Working with Numbered Lists in Open XML WordprocessingML
Working with Numbered Lists in Open XML WordprocessingML
Introducing the Open XML Format External File Converter for 2007 Office System SP2
Editing Data in an Excel 2007 Open XML File with VBA
Creating Documents by Using the Open XML Format SDK Version 2.0 CTP (Part 1 of 3)
Creating Documents by Using the Open XML Format SDK 2.0 CTP (Part 2 of 3)
Creating Documents by Using the Open XML Format SDK 2.0 CTP (Part 3 of 3)
Using Office Open XML to Save Time Without Writing Code
Taking the 2007 Office System Further with VBA and Open XML Formats
Using Office Open XML to Customize Document Formatting in the 2007 Office System
Getting More from Document Themes in the 2007 Office System with Office Open XML
Creating Business Applications by Using Excel Services and Office Open XML Formats
Creating a Simple Search and Replace Utility for Word 2007 Open XML Format Documents
Using Office Open XML Formats to Support Electronic Health Records Portability and Health Industry Standards
Creating Document Themes with the Office Open XML Formats
Inserting Repeating Data Items into a Word 2007 Table by Using the Open XML API
Building Server-Side Document Generation Solutions Using the Open XML Object Model (Part 1 of 2)
Building Server-Side Document Generation Solutions Using the Open XML Object Model (Part 2 of 2)
Manipulating Word 2007 Files with the Open XML Format API (Part 1 of 3)
Manipulating Word 2007 Files with the Open XML Format API (Part 2 of 3)
Manipulating Word 2007 Files with the Open XML Format API (Part 3 of 3)
Manipulating Excel 2007 and PowerPoint 2007 Files with the Open XML Format API (Part 1 of 2)
Manipulating Excel 2007 and PowerPoint 2007 Files with the Open XML Format API (Part 2 of 2)

Creating Excel Files from DataSet using OpenXML 2.0 – C#

September 26, 2010 .NET, All, C#.NET, Microsoft, Microsoft SDKs, Office, Open XML 3 comments

Introduction

It is quite often we programmers have to develop business applications which provides the facility for the end-user, such as “Export to Excel”, dumping report information to an Excel worksheet and mail them to the user. Since excel is a good medium to generate easy to use reports, calculation, sales forcasts etc.

Imagine that you need to retrieve a list of all the worksheets within an Excel workbook or set of workbooks. The ability to perform this operation without requiring you to load Excel 2007 and then load the workbooks, one after another, can be an incredible time saver.

I was looking for different alternatives to write genuine Excel files.  I was familiar with the two options

1. Using JET OLEDB Provider and reading/writing excel files using OLEDB Connection.  (This is a pretty good way of reading and writing excel file considering the file itself as DataSource for OLEDB Connection. The problem is deleting recording is not possible, this is a serious limitation. Some times we would be needed to clear all the contents from Excel sheet and write contents freshly)

  1. Using Microsoft Office Excel Interoperability COM assemblies. (This requires the Microsoft Office Excel Suite to be installed on the target system, this is costly some of our clients will not opt for it, because of the license cost). 

Because of the limitations of above two options, we have to look for another alternative. A set of Costly third party libraries or Microsoft’s own open library “Open XML”. With introduction of Office 2007, things are changed. The Office Open XML File Formats(XLSX, DOCX ,PPTX) make this task possible. Working with the Office Open XML File Formats requires knowledge of the way Excel stores its content, the System.IO.Packaging API, and XML programming.

Introduction to Open XML

Office Open XML (also informally known as OOXML or OpenXML) is a zipped, XML-based file format developed by Microsoft for representing spreadsheets, charts, presentations and word processing documents. The Office Open XML specification has been standardised by Ecma. A later edition was standardized by ISO and IEC as an International Standard (ISO/IEC 29500); this edition is still not implemented in any products.

Starting with Microsoft Office 2007, the Office Open XML file formats (ECMA-376) have become the default target file format of Microsoft Office, although the Strict variant of the standard is not fully supported. Microsoft Office 2010 provides read support for ECMA-376, read/write support for ISO/IEC 29500 Transitional, and read support for ISO/IEC 29500 Strict.

Reference Links: OpenXML Developer WebSite, 

Required Files for using OpenXML with C# / VB.NET

Open XML SDK 2.0 for Microsoft Office  – download

Open XML SDK 2.0 provides an open source library DocumentFormat.OpenXml.dll using this library, .net developers can leverage the power of reading/writing Microsoft Office documents (PPTX, XLSX, DOCX) – From Microsoft Office 2007 onwards Microsoft focusing on Open XML based document types (PowerPoint: PPTX, Excel: XLSX, Document: DOCX) .

Not to be confused with OpenOffice.org XML (a deprecated format used by early versions of OpenOffice.org), or Microsoft Office XML formats (deprecated formats used by earlier versions of Microsoft Office).
Microsoft Office Word 2003 XML Format — WordProcessingML or WordML (.XML)
Microsoft Office Excel 2002 and Excel 2003 XML Format — SpreadsheetML (.XML)
Microsoft Office Visio 2003 XML Format — DataDiagramingML (.VDX, .VSX, .VTX)
Microsoft Office InfoPath 2003 XML Format — XML FormTemplate (.XSN) (Compressed XML templates in a Cabinet file)

These are all deprecated now after the release of Office 2007, which came with Open XML Formats( XLSX, PPTX, DOCX), and open wide variaty of programming options for the developers.

Here I am going to discuss / demonstrate only about the Excel (XSLX) file format. With Open XML we can create Charts, Calculations, alter existing Excel sheet contents, write new worksheet. Extensibility of Excel document creation is in your hand now.

For demonstrate the Excel document format & Relationships, I am going to use a diagram lend from CodeProject article Reading & Writing Open XML Files.

From the above diagram you will get an exact idea how the Excel – Open XML relational structure. Workbook with multiple worksheets, you can customize the styles and settings for the workbook or per sheets in the Excel file. There are more to discuss about the things in details, but my time is limited and I am going to provide few helpful reference links in the end of this article. With which you will get an idea about Open XML.

My Sample Solution – Source Code

I decided to build a Utility class which will be reusable, so that other business logic classes can utilize this method for reading & writing excel document with help of Open XML 2.0 library DocumentFormat.OpenXml.dll .

My solution is a console application consist of

Created a Solution named : ConsoleApp

Add reference to DocumentFormat.OpenXml.dll (Open XML 2.0 Library)

ExcelUtils.cs -> The implementation utility class consisting the necessary methods for writing excel file taking input in the form of a DataSet(consisting of multiple tables, transformed in to multiple worksheets while writing to EXCEL). This class also has the methods to clear existing contents from a worksheet, delete a worksheet, create a new worksheet if not exists and if worksheet exists append the records.

Create(string fileName, DataSet inputDataSet) -> this method creates a new Excel file in specified path from the inputDataSet. This is limited to write/overwrite only, this method doesn’t check for sheet already exist or not. This method is developed in LinQ based expression for converting the DataSet to a hirachical List.

SaveWorkbook(string fileName, DataSet inputData, bool overwriteContents, bool clearHeader ) This method has the logic to create / modify an excel sheet.
Parameters : overwriteContents – This will clear all contents from a worksheet except the header.
clearHeader – Clear the header /column defenition also from worksheet when overwriteContents = true.
DeleteWorkSheet(string fileName, string sheetToDelete) Deletes a worksheet from an existing excel file.


using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Text;
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;

namespace ConsoleApp
{
    /// <summary>
    ///
    /// </summary>
    public class ExcelUtils
    {
        /// <summary>
        /// Builds the workbook.
        /// </summary>
        /// <param name="fileName">Name of the file.</param>
        /// <param name="inputData">The input data.</param>
        /// <param name="overwriteContents"></param>
        /// <param name="clearHeader"></param>
        public void SaveWorkbook(string fileName, DataSet inputData, bool overwriteContents, bool clearHeader )
        {
            SpreadsheetDocument spreadsheetDocument;
            bool isNewFile = false;
            try
            {

                if (!File.Exists(fileName))
                {
                    spreadsheetDocument = SpreadsheetDocument.Create(fileName, SpreadsheetDocumentType.Workbook); //Create
                    isNewFile = true;
                }
                else
                {
                    spreadsheetDocument = SpreadsheetDocument.Open(fileName, true); //Opening exisiting
                    isNewFile = false;
                }

                if(true)//using (spreadsheetDocument)
                {

                    WorkbookPart workbookPart;

                    //Instantiates workbookpart
                    if (isNewFile)
                        workbookPart = spreadsheetDocument.AddWorkbookPart(); //If file is new file
                    else
                        workbookPart = spreadsheetDocument.WorkbookPart;

                    //Creates Workbook if workbook not existed(For New Excel File), Existing excel file this is not necessary
                    if (workbookPart.Workbook == null)
                         workbookPart.Workbook  = new Workbook();

                    Sheets sheets ;

                    //
                    if(isNewFile)
                        sheets = workbookPart.Workbook.AppendChild(new Sheets()); //Adding new sheets to the file, if new file
                    else
                        sheets = workbookPart.Workbook.Sheets; //Retrieving existing sheets from the file

                    FileVersion fileVersion = new FileVersion { ApplicationName = "Microsoft Office Excel" };
                   //  workbook.Append(fileVersion);

                    uint tableIndex = 0;

                    //converting the sheets collection to a list of <Sheet>
                    List<Sheet> sheetsList = workbookPart.Workbook.Descendants<Sheet>().ToList();

                    // If the InputDataSet having 1 or more tables, looping through and
                    // creates new sheet for each table and dumps the data to the sheet
                    // and saves the excel workbook.
                    foreach (DataTable inputDataTable in inputData.Tables)
                    {
                        bool hasSheetExists = false;
                        int sheetIndex = 0;
                        string relId = "";
                        Sheet sheet;

                        //Checking sheet exists in the excel file.
                        sheetIndex   =  sheetsList.FindIndex(c => c.Name == inputDataTable.TableName);

                        if( sheetIndex >= 0)
                        {
                            hasSheetExists = true;
                        }

                        WorksheetPart worksheetPart;

                        if(!hasSheetExists) //If a new sheet
                        {

                            worksheetPart = workbookPart.AddNewPart<WorksheetPart>();
                            relId = workbookPart.GetIdOfPart(worksheetPart);
                            sheet = new Sheet { Name = inputDataTable.TableName, SheetId = tableIndex + 1, Id = relId };
                        }
                        else // if sheet already exists
                        {
                             sheet = sheetsList[sheetIndex];

                            List<WorksheetPart> partList = workbookPart.WorksheetParts.ToList();

                             // Take the existing the sheet reference from the workbook.
                            WorksheetPart worksheetPart1 = (WorksheetPart)(workbookPart.GetPartById(sheet.Id));

                            worksheetPart = worksheetPart1;

                            //Retriving RelationID form the workbookPart
                            relId = workbookPart.GetIdOfPart(worksheetPart);
                            // partList.FindAll( c=> c.)
                           // worksheetPart = workbookPart.AddNewPart<WorksheetPart>();
                        }

                        SheetData sheetData = new SheetData();

                        Worksheet workSheet = worksheetPart.Worksheet;

                        int lastRowIndex = 0;

                        if (workSheet != null)
                        {
                            //Retrieving existing sheet data from the worksheet
                            sheetData = workSheet.GetFirstChild<SheetData>();

                            if(overwriteContents) //Clearing the contents of the Sheet, except the header
                            {
                                int endIndex = 1;

                                //if value true clear the existing header
                                if (clearHeader)
                                    endIndex = 0;

                                //Deleting content row by row, starting from the bottom.
                                for (int childIndex = sheetData.ChildElements.Count - 1; childIndex >= endIndex; childIndex--)
                                {
                                    sheetData.RemoveChild(sheetData.ChildElements[childIndex]);
                                }
                            }

                            //Getting all existing record rows.
                            IEnumerable<Row> rows = sheetData.Descendants<Row>();

                            //Considering the last row index as total row count. append the records to the last index onwards.
                            lastRowIndex = rows.Count();
                        }
                        else //Creating new worksheet
                        {
                            workSheet = new Worksheet(sheetData);
                            worksheetPart.Worksheet = workSheet;
                        }

                        //If Data Table is not empty
                        if (inputDataTable != null && inputDataTable.Rows.Count > 0)
                        {
                            //If Not Sheet already exists(Based on Table Name) -- creating column headers for the excel sheet
                            if (!hasSheetExists || lastRowIndex < 1)
                            {
                                //Creating columns..(INDX = 1 , Header)
                                Row headerRow = CreateContentHeader(1, inputDataTable.Columns);
                                sheetData.Append(headerRow);
                                lastRowIndex = 1;
                            }

                            //Last Row index
                            lastRowIndex++;

                            //Worksheet Data Row Number.. (INDX = 2 onwards data)
                            uint currDataRowIndex = (uint) lastRowIndex; //From this index on data will get appended.

                            //Creating Row Data
                            for (int iterRowIndex = 0; iterRowIndex < inputDataTable.Rows.Count; iterRowIndex++)
                            {
                                //Retrieving current DataRow from DataTable
                                DataRow currentInputRow = inputDataTable.Rows[iterRowIndex];

                                //Creating insertble row for the openxml.
                                Row contentRow = CreateContentRow(currDataRowIndex, currentInputRow,
                                                                  inputDataTable.Columns);
                                currDataRowIndex++;

                                //Appending to sheet data
                                sheetData.AppendChild(contentRow);
                            }
                        }

                        //new Worksheet(sheetData);

                        //Saving worksheet contents
                        worksheetPart.Worksheet.Save();

                        //If sheet new, then appending to sheets collection
                        if(!hasSheetExists)
                         sheets.AppendChild(sheet);

                        tableIndex++;

                    }

                    //Saving the complete workbook to disk
                    spreadsheetDocument.WorkbookPart.Workbook.Save();

                    spreadsheetDocument.Close();

                }

            }

            catch (Exception)
            {
               // spreadsheetDocument.Close();
                throw;

            }

        }

        /// <summary>
        /// Creates the content header.
        /// </summary>
        /// <param name="rowDataIndex">Index of the row data.</param>
        /// <param name="dataColumns">The data columns.</param>
        /// <returns></returns>
        private Row CreateContentHeader(UInt32 rowDataIndex, DataColumnCollection dataColumns)
        {
            Row resultRow = new Row { RowIndex = rowDataIndex };

            for (int iterColIndex = 0; iterColIndex < dataColumns.Count; iterColIndex++)
            {
                Cell cell1 = CreateHeaderCell(dataColumns[iterColIndex].ColumnName, rowDataIndex, dataColumns[iterColIndex].ColumnName);  //CreateTextCell("A", rowDataIndex, Convert.ToString(dataRow[iterColIndex]));
                resultRow.Append(cell1);

            }

            return resultRow;
        }

        /// <summary>
        /// Creates the content row.
        /// </summary>
        /// <param name="rowDataIndex">The rowDataIndex.</param>
        /// <param name="dataRow">DataRow</param>
        /// <param name="dataColumns">DataColumnCollection</param>
        /// <returns></returns>
        private  Row CreateContentRow(UInt32 rowDataIndex, DataRow dataRow,DataColumnCollection dataColumns)
        {

            Row resultRow = new Row { RowIndex = rowDataIndex };

            for(int iterColIndex =0; iterColIndex < dataColumns.Count; iterColIndex ++)
            {
                Cell cell1 = CreateContentCell(dataColumns[iterColIndex].ColumnName, rowDataIndex, dataRow[iterColIndex]);  //CreateTextCell("A", rowDataIndex, Convert.ToString(dataRow[iterColIndex]));
                resultRow.Append(cell1);

            }

            return resultRow;

        }

        /// <summary>
        /// Creates the content cell.
        /// </summary>
        /// <param name="header">The header.</param>
        /// <param name="index">The rowDataIndex.</param>
        /// <param name="inputValue">The input value.</param>
        /// <returns></returns>
        private Cell CreateContentCell(string header, UInt32 index,  object  inputValue)
        {
            Cell resultCell = null;

            Type objectType = inputValue.GetType();

            TypeCode objectTypeCode;

            bool parseSuccess = Enum.TryParse(objectType.Name, true, out objectTypeCode);

            if (parseSuccess)
            {
                switch (objectTypeCode)
                {
                    // Number Fields
                    case TypeCode.UInt64:
                    case TypeCode.UInt32:
                    case TypeCode.UInt16:
                    case TypeCode.Int64:
                    case TypeCode.Int32:
                    case TypeCode.Int16:
                    case TypeCode.Double :
                    case TypeCode.Decimal :
                        resultCell = CreateNumberCell(header, index, inputValue);
                        break;
                    // Date Time Field
                    case TypeCode.DateTime :
                        resultCell = CreateDateCell(header, index, inputValue);
                        break;
                    // Boolean Field
                    case TypeCode.Boolean:
                        resultCell = CreateBooleanCell(header, index, inputValue);
                        break;

                    default :
                       resultCell  =  CreateTextCell(header, index, inputValue);
                        break;
                        //case TypeCode.
                }
            }
            else
               resultCell =  CreateTextCell(header, index, inputValue);
            return resultCell;
        }

        /// <summary>
        /// Creates the header cell.
        /// </summary>
        /// <param name="header">The header.</param>
        /// <param name="index">The index.</param>
        /// <param name="text">The text.</param>
        /// <returns></returns>
        private Cell CreateHeaderCell(string header, UInt32 index, object text)
        {
            Cell c = new Cell { DataType = CellValues.String, CellReference = header + index };

            CellValue cellValue = new CellValue
                              {
                                  Text = Convert.ToString(text),
                              };

            c.Append(cellValue);

            return c;

        }

        /// <summary>
        /// Creates the text cell.
        /// </summary>
        /// <param name="header">The header.</param>
        /// <param name="index">The rowDataIndex.</param>
        /// <param name="text">The text.</param>
        /// <returns></returns>
        private  Cell CreateTextCell(string header, UInt32 index, object text)
        {

            Cell c = new Cell { DataType = CellValues.InlineString, CellReference = header + index };

            InlineString istring = new InlineString();

            Text t = new Text { Text = Convert.ToString(text) };

            istring.Append(t);

            c.Append(istring);

            return c;

        }

        /// <summary>
        /// Creates the number cell.
        /// </summary>
        /// <param name="header">The header.</param>
        /// <param name="index">The rowDataIndex.</param>
        /// <param name="number">The number.</param>
        /// <returns></returns>
        private Cell CreateNumberCell(string header, UInt32 index, object number)
        {

            Cell c = new Cell
            {
                CellReference = header + index,
                DataType = CellValues.Number
            };

            CellValue v = new CellValue
            {
                Text = Convert.ToString(number),
               // DataType = CellValues.Number,
            };

            c.Append(v);

            return c;

        }

        /// <summary>
        /// Creates the date cell.
        /// </summary>
        /// <param name="header">The header.</param>
        /// <param name="index">The rowDataIndex.</param>
        /// <param name="number">The date.</param>
        /// <returns></returns>
        private Cell CreateDateCell(string header, UInt32 index, object date)
        {

            Cell c = new Cell
            {
                CellReference = header + index,
                DataType = CellValues.Date
            };

            CellValue v = new CellValue
            {
                Text = Convert.ToString(date),
                // DataType = CellValues.Number,
            };

            c.Append(v);

            return c;

        }

        /// <summary>
        /// Creates the date cell.
        /// </summary>
        /// <param name="header">The header.</param>
        /// <param name="index">The rowDataIndex.</param>
        /// <param name="number">The date.</param>
        /// <returns></returns>
        private Cell CreateBooleanCell(string header, UInt32 index, object boolVal)
        {

            Cell c = new Cell
            {
                CellReference = header + index,
                DataType = CellValues.Boolean
            };

            CellValue v = new CellValue
            {
                Text = Convert.ToString(boolVal),
                // DataType = CellValues.Number,
            };

            c.Append(v);

            return c;

        }

        #region DeleteWorksheet()

        /// <summary>
        /// Deletes the A work sheet.
        /// </summary>
        /// <param name="fileName">Name of the file.</param>
        /// <param name="sheetToDelete">The sheet to delete.</param>
        public void DeleteWorkSheet(string fileName, string sheetToDelete)
        {
            string Sheetid = "";
            //Open the workbook
            using (SpreadsheetDocument document = SpreadsheetDocument.Open(fileName, true))
            {
                WorkbookPart wbPart = document.WorkbookPart;

                // Get the pivot Table Parts
                IEnumerable<PivotTableCacheDefinitionPart> pvtTableCacheParts = wbPart.PivotTableCacheDefinitionParts;
                Dictionary<PivotTableCacheDefinitionPart, string> pvtTableCacheDefinationPart = new Dictionary<PivotTableCacheDefinitionPart, string>();
                foreach (PivotTableCacheDefinitionPart Item in pvtTableCacheParts)
                {
                    PivotCacheDefinition pvtCacheDef = Item.PivotCacheDefinition;
                    //Check if this CacheSource is linked to SheetToDelete
                    var pvtCahce = pvtCacheDef.Descendants<CacheSource>().Where(s => s.WorksheetSource.Sheet == sheetToDelete);
                    if (pvtCahce.Count() > 0)
                    {

                        pvtTableCacheDefinationPart.Add(Item, Item.ToString());
                    }
                }
                foreach (var Item in pvtTableCacheDefinationPart)
                {
                    wbPart.DeletePart(Item.Key);
                }
                //Get the SheetToDelete from workbook.xml
                Sheet theSheet = wbPart.Workbook.Descendants<Sheet>().Where(s => s.Name == sheetToDelete).FirstOrDefault();
                if (theSheet == null)
                {
                    // The specified sheet doesn't exist.
                }
                //Store the SheetID for the reference
                Sheetid = theSheet.SheetId;

                // Remove the sheet reference from the workbook.
                WorksheetPart worksheetPart = (WorksheetPart)(wbPart.GetPartById(theSheet.Id));
                theSheet.Remove();

                // Delete the worksheet part.
                wbPart.DeletePart(worksheetPart);

                //Get the DefinedNames
                var definedNames = wbPart.Workbook.Descendants<DefinedNames>().FirstOrDefault();
                if (definedNames != null)
                {
                    foreach (DefinedName Item in definedNames)
                    {
                        // This condition checks to delete only those names which are part of Sheet in question
                        if (Item.Text.Contains(sheetToDelete + "!"))
                            Item.Remove();
                    }
                }
                // Get the CalculationChainPart
                //Note: An instance of this part type contains an ordered set of references to all cells in all worksheets in the
                //workbook whose value is calculated from any formula

                CalculationChainPart calChainPart;
                calChainPart = wbPart.CalculationChainPart;
                if (calChainPart != null)
                {
                    var calChainEntries = calChainPart.CalculationChain.Descendants<CalculationCell>().Where(c => c.SheetId == Sheetid);
                    foreach (CalculationCell Item in calChainEntries)
                    {
                        Item.Remove();
                    }
                    if (calChainPart.CalculationChain.Count() == 0)
                    {
                        wbPart.DeletePart(calChainPart);
                    }
                }

                // Save the workbook.
                wbPart.Workbook.Save();
            }
        }

        #endregion

        #region  ClearWorkSheetData

        /// <summary>
        /// Deletes the A work sheet.
        /// </summary>
        /// <param name="fileName">Name of the file.</param>
        /// <param name="sheetToDelete">The sheet to delete.</param>
        public void ClearWorkSheetData(string fileName, string sheetToClear)
        {
            string Sheetid = "";
            //Open the workbook
            using (SpreadsheetDocument document = SpreadsheetDocument.Open(fileName, true))
            {
                WorkbookPart wbPart = document.WorkbookPart;

                // Get the pivot Table Parts
                IEnumerable<PivotTableCacheDefinitionPart> pvtTableCacheParts = wbPart.PivotTableCacheDefinitionParts;
                Dictionary<PivotTableCacheDefinitionPart, string> pvtTableCacheDefinationPart = new Dictionary<PivotTableCacheDefinitionPart, string>();
                foreach (PivotTableCacheDefinitionPart Item in pvtTableCacheParts)
                {
                    PivotCacheDefinition pvtCacheDef = Item.PivotCacheDefinition;
                    //Check if this CacheSource is linked to SheetToDelete
                    var pvtCahce = pvtCacheDef.Descendants<CacheSource>().Where(s => s.WorksheetSource.Sheet == sheetToClear);
                    if (pvtCahce.Count() > 0)
                    {

                        pvtTableCacheDefinationPart.Add(Item, Item.ToString());
                    }
                }
                foreach (var Item in pvtTableCacheDefinationPart)
                {
                    wbPart.DeletePart(Item.Key);
                }
                //Get the SheetToDelete from workbook.xml
                Sheet theSheet = wbPart.Workbook.Descendants<Sheet>().Where(s => s.Name == sheetToClear).FirstOrDefault();
                if (theSheet == null)
                {
                    // The specified sheet doesn't exist.
                }
                //Store the SheetID for the reference
                Sheetid = theSheet.SheetId;

                // Remove the sheet reference from the workbook.
                WorksheetPart worksheetPart = (WorksheetPart)(wbPart.GetPartById(theSheet.Id));

                Worksheet workSheet = worksheetPart.Worksheet;
                SheetData sheetData = workSheet.GetFirstChild<SheetData>();

                for(int childIndex = 1; childIndex < sheetData.ChildElements.Count; childIndex ++)
                {
                    sheetData.RemoveChild(sheetData.ChildElements[childIndex]);
                }

                IEnumerable<Row> rows = sheetData.Descendants<Row>();

                List<Row> rowsList = rows.ToList();

                //rowsList.RemoveRange(1, rowsList.Count - 1);

                // Save the workbook.
                wbPart.Workbook.Save();
            }
        }

        #endregion

        #region Create(string fileSavePath, DataSet dataSet)

        /// <summary>
        /// Saves the specified file save path.
        /// </summary>
        /// <param name="fileSavePath">The file save path.</param>
        /// <param name="dataSet">The data set.</param>
        public void Create(string fileSavePath, DataSet dataSet)
        {

            Dictionary<string, List<OpenXmlElement>> inputDictionary = ToSheets(dataSet);

            Create(fileSavePath, inputDictionary);
           // inputDictionary
        }

        /// <summary>
        /// Creates the specified path.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="sets">The sets.</param>
        private void Create(string path, Dictionary<String, List<OpenXmlElement>> sets)
        {
            using (SpreadsheetDocument package = SpreadsheetDocument.Create(path, SpreadsheetDocumentType.Workbook))
            {
                WorkbookPart workbookpart = package.AddWorkbookPart();
                workbookpart.Workbook = new Workbook();

                Sheets sheets = workbookpart.Workbook.AppendChild(new Sheets());

                foreach (KeyValuePair<String, List<OpenXmlElement>> set in sets)
                {
                    WorksheetPart worksheetpart = workbookpart.AddNewPart<WorksheetPart>();
                    worksheetpart.Worksheet = new Worksheet(new SheetData(set.Value));
                    worksheetpart.Worksheet.Save();

                    Sheet sheet = new Sheet()
                    {
                        Id = workbookpart.GetIdOfPart(worksheetpart),
                        SheetId = (uint)(sheets.Count() + 1),
                        Name = set.Key
                    };
                    sheets.AppendChild(sheet);
                }
                workbookpart.Workbook.Save();
            }
        }

        /// <summary>
        /// Toes the sheets.
        /// </summary>
        /// <param name="ds">The ds.</param>
        /// <returns></returns>
        private Dictionary<string, List<OpenXmlElement>> ToSheets(DataSet ds)
        {
            return
                (from dt in ds.Tables.OfType<DataTable>()
                 select new
                 {
                     // Sheet Name
                     Key = dt.TableName,
                     Value = (
                         // Sheet Columns
                     new List<OpenXmlElement>(
                        new OpenXmlElement[]
                {
                    new Row(
                        from d in dt.Columns.OfType<DataColumn>()
                        select (OpenXmlElement)new Cell()
                        {
                            CellValue = new CellValue(d.ColumnName),
                            DataType = CellValues.String
                        })
                })).Union
                         // Sheet Rows
                     ((from dr in dt.Rows.OfType<DataRow>()
                       select ((OpenXmlElement)new Row(from dc in dr.ItemArray
                                                       select (OpenXmlElement)new Cell()
                                                       {
                                                           CellValue = new CellValue(dc.ToString()),
                                                           DataType = CellValues.String
                                                       })))).ToList()
                 }).ToDictionary(p => p.Key, p => p.Value);
        }

        #endregion

        #region Read

        /// <summary>
        /// Reads the specified file save path.
        /// </summary>
        /// <param name="fileSavePath">The file save path.</param>
        /// <returns></returns>
        public DataSet Read(string fileSavePath)
        {

            DataSet resultSet = new DataSet();

            using (SpreadsheetDocument spreadSheetDocument = SpreadsheetDocument.Open(fileSavePath, false))
            {

                WorkbookPart workbookPart = spreadSheetDocument.WorkbookPart;
                IEnumerable<Sheet> sheets = spreadSheetDocument.WorkbookPart.Workbook.GetFirstChild<Sheets>().Elements<Sheet>();

                foreach (Sheet sheet in sheets)
                {
                    DataTable dt = new DataTable();

                    string relationshipId = sheet.Id.Value;
                    string sheetName      = sheet.SheetId;
                    dt.TableName            = sheet.SheetId;

                    WorksheetPart worksheetPart =
                        (WorksheetPart) spreadSheetDocument.WorkbookPart.GetPartById(relationshipId);
                    Worksheet workSheet = worksheetPart.Worksheet;
                    SheetData sheetData = workSheet.GetFirstChild<SheetData>();
                    IEnumerable<Row> rows = sheetData.Descendants<Row>();

                    foreach (Cell cell in rows.ElementAt(0))
                    {
                        dt.Columns.Add(GetCellValue(spreadSheetDocument, cell));
                    }

                    List<Row> rowsList = new List<Row>();

                    rowsList = rows.ToList();

                    //Start from 1, first row is header.
                    for ( int iterRowIndex = 1 ; iterRowIndex  < rowsList.Count ; iterRowIndex ++) //this will also include your header row...
                    {
                        Row row = rowsList[iterRowIndex];

                        DataRow tempRow = dt.NewRow();

                        for (int i = 0; i < row.Descendants<Cell>().Count(); i++)
                        {
                            tempRow[i] = GetCellValue(spreadSheetDocument, row.Descendants<Cell>().ElementAt(i));
                        }

                        dt.Rows.Add(tempRow);
                    }

                    resultSet.Tables.Add(dt);
                }

            }

            return resultSet;
        }

        /// <summary>
        /// Gets the cell value.
        /// </summary>
        /// <param name="document">The document.</param>
        /// <param name="cell">The cell.</param>
        /// <returns></returns>
        public static string GetCellValue(SpreadsheetDocument document, Cell cell)
        {
            SharedStringTablePart stringTablePart = document.WorkbookPart.SharedStringTablePart;
            string value = cell.CellValue != null ? cell.CellValue.InnerXml : string.Empty;

            if (cell.DataType != null && cell.DataType.Value == CellValues.SharedString)
            {
                return stringTablePart.SharedStringTable.ChildElements[Int32.Parse(value)].InnerText;
            }
            else
            {
                return value;
            }
        }

        #endregion
    }
}

Program.cs  -> The entry point method in which I will be creating the DUMMY Dataset, to pass as input to SaveWorksheet(string fileSavePath, DataSet ds) method.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Data;

namespace ConsoleApp
{
    class Program
    {
        /// <summary>
        /// Mains the specified args.
        /// </summary>
        /// <param name="args">The args.</param>
        static void Main(string[] args)
        {

            ExcelUtils excelUtils = new ExcelUtils();

            DataSet dummySet = CreateDummyDataSet();

            excelUtils.SaveWorkbook("c:Test9.xlsx", dummySet,true,true);

           // excelUtils.Save("c:Test7.xlsx", dummySet);
            DataSet dsNewSet =  excelUtils.Read("c:Test9.xlsx");

            Console.Read();
        }

        /// <summary>
        /// Creates the dummy data set.
        /// </summary>
        /// <returns></returns>
        public static DataSet CreateDummyDataSet()
        {
            DataSet resultSet = new DataSet();

            for (int tableIndex = 0; tableIndex < 5; tableIndex ++ )
            {
                DataTable dataTable = new DataTable("Table" + tableIndex.ToString());

                for (int colIndex = 0; colIndex < 10; colIndex++)
                {
                    if(colIndex % 2 == 0)
                    {
                        dataTable.Columns.Add("Column" + colIndex.ToString(), Type.GetType("System.Decimal"));
                    }
                    else
                    {
                        dataTable.Columns.Add("Column" + colIndex.ToString(), Type.GetType("System.String"));
                    }
                }

                for(int rowIndex = 0; rowIndex < 20000; rowIndex++)
                {
                    DataRow dataRow = dataTable.NewRow();

                    for (int colIndex = 0; colIndex < dataTable.Columns.Count; colIndex++)
                    {
                        if (colIndex % 2 == 0)
                        {
                            dataRow[dataTable.Columns[colIndex].ColumnName] = (rowIndex* (colIndex+1)) + colIndex;
                        }
                        else
                        {
                            dataRow[dataTable.Columns[colIndex].ColumnName] = "STR : " + (rowIndex * (colIndex + 1)) + colIndex;
                        }

                    }
                    dataTable.Rows.Add(dataRow);
                }
                resultSet.Tables.Add(dataTable);
            }

            return resultSet;
        }

    }
}

The above code snippets writes / appends the input DataSet content to Excel File.

This just a sample code and I have tested the code on appending records to existing sheet, clearing the existing contents and write records to the file or delete a worksheet from the existing excel file.

Helpful Links / References:

Reading & Writing Open XML Files – Code Project

OpenXML Developer WebSite

Wikipedia.ORG

Office Open XML Formats: Retrieving Lists of Excel 2007 Worksheets

An introduction to Open XML SDK 2.0

You can modify the code according to your need and can refer to it for understanding about Open XML for EXCEL. If you have any doubts or queris regarding the code snippet, please mail me to nithinmohantk (at) nitrix-reloaded.com . I will help you the way i could, also if interested follow me on Twitter(@nithinmohantk), FaceBook(nithinmohantk)