Quantcast
Channel: ClosedXML - The easy way to OpenXML
Viewing all 1877 articles
Browse latest View live

New Comment on "Named Ranges"

$
0
0
@ manjunathg88 wb.NamedRanges.ToList()

New Comment on "Named Ranges"

$
0
0
@manjunathg88 wb.NamedRanges.ToList()

New Comment on "Styles - Font"

$
0
0
I want to convert a windows font to xlfont and use it in the class. is it possible?

Updated Wiki: Home

$
0
0
We are moving to GitHUB, please use https://github.com/Pyropace/ClosedXML

 

Project Description

ClosedXML makes it easier for developers to create Excel 2007/2010 files. It provides a nice object oriented way to manipulate the files (similar to VBA) without dealing with the hassles of XML Documents. It can be used by any .NET language like C# and Visual Basic (VB).


What can you do with this?

ClosedXML allows you to create Excel 2007/2010 files without the Excel application. The typical example is creating Excel reports on a web server.

If you've ever used the Microsoft Open XML Format SDK you know just how much code you have to write to get the same results as the following 4 lines of code.

            var workbook = new XLWorkbook();
            var worksheet = workbook.Worksheets.Add("Sample Sheet");
            worksheet.Cell("A1").Value = "Hello World!";
            workbook.SaveAs("HelloWorld.xlsx");



Something more elaborate:

The Documentation page has an example of how to create the following table (Showcase) as well as many other examples:

Showcase.jpg

 

 Sponsors:

E-iceblue is a community sponsor of ClosedXML. E-iceblue components enable developers to Open, Create, Modify, Convert, Print, View MS Word, Excel, PowerPoint, PDF documents.

 

 

 

 

Updated Wiki: Home

$
0
0
We are moving to GitHUB, please use https://github.com/closedxml/closedxml

 

Project Description

ClosedXML makes it easier for developers to create Excel 2007/2010 files. It provides a nice object oriented way to manipulate the files (similar to VBA) without dealing with the hassles of XML Documents. It can be used by any .NET language like C# and Visual Basic (VB).


What can you do with this?

ClosedXML allows you to create Excel 2007/2010 files without the Excel application. The typical example is creating Excel reports on a web server.

If you've ever used the Microsoft Open XML Format SDK you know just how much code you have to write to get the same results as the following 4 lines of code.

            var workbook = new XLWorkbook();
            var worksheet = workbook.Worksheets.Add("Sample Sheet");
            worksheet.Cell("A1").Value = "Hello World!";
            workbook.SaveAs("HelloWorld.xlsx");



Something more elaborate:

The Documentation page has an example of how to create the following table (Showcase) as well as many other examples:

Showcase.jpg

 

 Sponsors:

E-iceblue is a community sponsor of ClosedXML. E-iceblue components enable developers to Open, Create, Modify, Convert, Print, View MS Word, Excel, PowerPoint, PDF documents.

 

 

 

 

Updated Wiki: Home

$
0
0
We are moving to GitHUB, please use https://github.com/closedxml/closedxml

 

Project Description

ClosedXML makes it easier for developers to create Excel 2007/2010 files. It provides a nice object oriented way to manipulate the files (similar to VBA) without dealing with the hassles of XML Documents. It can be used by any .NET language like C# and Visual Basic (VB).


What can you do with this?

ClosedXML allows you to create Excel 2007/2010 files without the Excel application. The typical example is creating Excel reports on a web server.

If you've ever used the Microsoft Open XML Format SDK you know just how much code you have to write to get the same results as the following 4 lines of code.

            var workbook = new XLWorkbook();
            var worksheet = workbook.Worksheets.Add("Sample Sheet");
            worksheet.Cell("A1").Value = "Hello World!";
            workbook.SaveAs("HelloWorld.xlsx");



Something more elaborate:

The Documentation page has an example of how to create the following table (Showcase) as well as many other examples:

Showcase.jpg

 

 Sponsors:

E-iceblue is a community sponsor of ClosedXML. E-iceblue components enable developers to Open, Create, Modify, Convert, Print, View MS Word, Excel, PowerPoint, PDF documents.

 

 

 

 

Updated Wiki: Home

$
0
0
We are moving to GitHUB, please use https://github.com/closedxml/closedxml

 

Project Description

ClosedXML makes it easier for developers to create Excel 2007/2010 files. It provides a nice object oriented way to manipulate the files (similar to VBA) without dealing with the hassles of XML Documents. It can be used by any .NET language like C# and Visual Basic (VB).


What can you do with this?

ClosedXML allows you to create Excel 2007/2010 files without the Excel application. The typical example is creating Excel reports on a web server.

If you've ever used the Microsoft Open XML Format SDK you know just how much code you have to write to get the same results as the following 4 lines of code.

            var workbook = new XLWorkbook();
            var worksheet = workbook.Worksheets.Add("Sample Sheet");
            worksheet.Cell("A1").Value = "Hello World!";
            workbook.SaveAs("HelloWorld.xlsx");



Something more elaborate:

The Documentation page has an example of how to create the following table (Showcase) as well as many other examples:

Showcase.jpg

 

 Sponsors:

E-iceblue is a community sponsor of ClosedXML. E-iceblue components enable developers to Open, Create, Modify, Convert, Print, View MS Word, Excel, PowerPoint, PDF documents.

 

 

 

 

Updated Wiki: Home

$
0
0

We are moving!

The latest version of closedXMl and its source code can now be downloaded from our repository hosted at GitHub.

 

Project Description

ClosedXML makes it easier for developers to create Excel 2007/2010 files. It provides a nice object oriented way to manipulate the files (similar to VBA) without dealing with the hassles of XML Documents. It can be used by any .NET language like C# and Visual Basic (VB).


What can you do with this?

ClosedXML allows you to create Excel 2007/2010 files without the Excel application. The typical example is creating Excel reports on a web server.

If you've ever used the Microsoft Open XML Format SDK you know just how much code you have to write to get the same results as the following 4 lines of code.

            var workbook = new XLWorkbook();
            var worksheet = workbook.Worksheets.Add("Sample Sheet");
            worksheet.Cell("A1").Value = "Hello World!";
            workbook.SaveAs("HelloWorld.xlsx");



Something more elaborate:

The Documentation page has an example of how to create the following table (Showcase) as well as many other examples:

Showcase.jpg

 

 Sponsors:

E-iceblue is a community sponsor of ClosedXML. E-iceblue components enable developers to Open, Create, Modify, Convert, Print, View MS Word, Excel, PowerPoint, PDF documents.

 

 

 

 


New Post: XML Version

$
0
0
I was curious what XML standard this project using? I have a need to use XML 1.1 since I need some special characters to be involved.

Updated Wiki: Home

$
0
0

We are moving!

The latest version of closedXMl and its source code can now be downloaded from our repository hosted at GitHub.

 

Project Description

ClosedXML makes it easier for developers to create Excel 2007/2010 files. It provides a nice object oriented way to manipulate the files (similar to VBA) without dealing with the hassles of XML Documents. It can be used by any .NET language like C# and Visual Basic (VB).


What can you do with this?

ClosedXML allows you to create Excel 2007/2010 files without the Excel application. The typical example is creating Excel reports on a web server.

If you've ever used the Microsoft Open XML Format SDK you know just how much code you have to write to get the same results as the following 4 lines of code.

            var workbook = new XLWorkbook();
            var worksheet = workbook.Worksheets.Add("Sample Sheet");
            worksheet.Cell("A1").Value = "Hello World!";
            workbook.SaveAs("HelloWorld.xlsx");



Something more elaborate:

The Documentation page has an example of how to create the following table (Showcase) as well as many other examples:

Showcase.jpg

 

 

 

 

 

Commented Unassigned: Table Theme [9499]

$
0
0
Attached is an excel file with a custom Table Style. The loading of the table theme borks because enum.parse can't find a value. Recommend changing the theme to a string and using enum.tryparse. Have a helper that lets you get standard excel themes but still allows custom theme names.
Comments: [Github pull request](https://github.com/ClosedXML/ClosedXML/pull/6).

New Post: row.Cells() returning different number of cells for header and data rows

$
0
0
Hi,

When using row.Cells(), the number of cells returned for the header is 68 which is different for when i read the following rows of data which gives 67 cells.
Hence when i add the cells in a datatable they get out of synch.
There are data cells which are blank.

How to resolve this and read the same number of cells for each row?

Thanks,
SanjeevM.

Reviewed: ClosedXML 0.76.0 (Sep 09, 2016)

$
0
0
Rated 5 Stars (out of 5) - This is perfect. Just as the OpenXML Library should have being and not is. After some days of struggle with the Open XML SDK and its library I got my export function using ClosedXML after an hour. You guys and your library are my salvation. Chapeau!

Edited Unassigned: Datetime is 1 day off [9497]

$
0
0
Greetings,

I'm trying to write a datetime to a cell using ClosedXML. I set the IXLCell DataType to be XLCellValues.DateTime, and the value to be a new DateTime. I also set the number format id to 14 (mm/dd/yyyy)

When I look at the excel sheet, the date displayed is always one day larger than anticipated. When I read the cell value using ClosedXML (in a unit test), the value read from the file matches the value I wrote, but the actual excel sheet does not show the correct value.

Is this a bug in ClosedXML or am I missing something?

Thanks!
-Adam

New Comment on "Sorting Data"

$
0
0
The ws.Sort(4); has some kind of bug because it will sort on the 5th column, but then go back and sort on the 1st column, breaking up the row data

New Post: cell.RichText.Text v/s cell.Value.Tostring()

$
0
0
Hi,

I'm trying to read an excel file to get the formatted values for each cell and i'm having issues getting the correct value.
I have a cell with the value : 549.78
cell.RichText.Text is returning : (* 549,78) rather than 549.78

So shall i use cell.RichText.Text to get the formatted value or just use cell.Value.ToString()?

Thanks,
SanjeevM.

Updated Wiki: Documentation

$
0
0

We are moving!

The latest version of closedXMl and its source code can now be downloaded from our repository hosted at GitHub.

Please don't ask questions on the comments section of the documentation pages because Codeplex doesn't send notifications for them. Please use the discussion tab instead. Thanks.

Requirements:

To use ClosedXML you must reference the DocumentFormat.OpenXml.dll:

DocumentFormat.OpenXml.dll for NET 4.0+

DocumentFormat.OpenXml.dll for NET 3.5

 

FAQ

How do I deliver an Excel file in ASP.NET?
Does it support Excel 2003 and prior formats (.xls)?
How can I insert an image?
Text with numbers are getting converted to numbers, what's up with that?
How do I get the result of a formula?

Examples

Showcase - No nonsense example of how to use this API
Basic Table
Hello World - Proverbial hello world program

Real world scenarios

Finding and extracting the data

Time Savers

Simplifying your life...

Performance and Memory

Turning off events
Better lambdas
Where to use the using keyword
Other performance improvements

Misc

Data Types - How to handle and convert cell's data types (Text, Boolean, DateTime, Numeric)
Creating Multiple Worksheets
Organizing Sheets
Loading and Modifying Files
Using Lambda Expressions
Cell Values
Workbook Properties
Using Formulas
Evaluating Formulas- New
Creating Rows/Columns Outlines
Hide Unhide Row(s)/Column(s)
Freeze Panes
Copying Worksheets
Using Hyperlinks
Data Validation
Hide Worksheets
Sheet Protection
Tab Colors
Conditional Formatting
Pivot Table example

Inserting Data/Tables

Copying IEnumerable Collections - Using "cell.Value = collection"
Inserting Data - Using "cell.InsertData(collection)"
Inserting Tables - Using "cell.InsertTable(collection)"
Adding DataTable as Worksheet
Adding DataSet

Styles

Styles - Alignment
Styles - Border
Styles - Fill
Styles - Font
Styles - NumberFormat
NumberFormatId Lookup Table
Style Worksheet
Style Rows and Columns
Using Default Styles
Using Colors
ClosedXML Predefined Colors
Excel Indexed Colors
Using Rich Text
Using Phonetics

Ranges

Defining Ranges
Merging Cells
Clearing Ranges
Deleting Ranges
Multiple Ranges
Shifting Ranges
Transpose Ranges
Named Ranges
Accessing Named Ranges- New
Copying Ranges
Using Tables
Sorting Data
Selecting Cells and Ranges

Rows

Row Height and Styles
Selecting Rows
Inserting Rows
Inserting and Deleting Rows
Adjust Row Height and Column Width to Contents
Row Cells

Columns

Column Width and Styles
Selecting Columns
Inserting Columns
Inserting and Deleting Columns
Adjust Row Height and Column Width to Contents
Column Cells

Page Setup (Print Options)

Pages Tab
Paper Size Lookup Table
Margins Tab
Headers and Footers Tab
Sheet Tab
Print Areas and Page Breaks

AutoFilters

Adding an AutoFilter to a Range
Filter Values
Custom Filters

Comments

Visibility
Position
Signatures
Style - Alignment
Style - Colors and Lines
Style - Size
Style - Protection
Style - Properties
Style - Margins
Style - Web

New Post: Excel 2013 - 2010 compatibility

$
0
0
I know this is old, but just in case it helps someone, I got around this using the following code;
Private Sub FixWorkBook(ByVal ms As MemoryStream)
    Try
        Dim owb As SpreadsheetDocument = SpreadsheetDocument.Open(ms, True)

        For Each element In owb.WorkbookPart.Workbook.ChildElements
            If element.LocalName = "extLst" Then element.Remove()
        Next

        For Each element In owb.WorkbookPart.WorkbookStylesPart.Stylesheet.ChildElements
            If element.LocalName = "extLst" Then element.Remove()
        Next

        owb.Close()

    Catch ex As Exception
        LogError(ex, "FixWorkBook")
    End Try
End Sub

Commented Issue: "Unreadable content" when editing and reopening generated file in Excel 2010 [8466]

$
0
0
The problem is described in the discussions in the following thread: http://closedxml.codeplex.com/discussions/403797
When I open an existing Excel file using ClosedXml and save it (even without performing any actions), the file gets corrupted when it is edited using Excel 2010 afterwards. Excel 2007 and Excel 2013 do not produce the problem on my Systems (tested with WinXP and Win8).
I've attached the following small sample program:

```
namespace ClosedXml_Template_Test
{
using System.IO;
using ClosedXML.Excel;
class Program
{
static void Main(string[] args)
{
string inFilepath = "Template.xlsx";
string outFilepath = "Generated.xlsx";
byte[] fileContent;
using (FileStream fileStream = File.OpenRead(inFilepath))
{
// Read from file
fileContent = new byte[fileStream.Length];
fileStream.Read(fileContent, 0, fileContent.Length);
}
using (MemoryStream memStream = new MemoryStream())
{
// Write to MemoryStream
memStream.Write(fileContent, 0, fileContent.Length);
// Create ClosedXml instances
using (XLWorkbook workbook = new XLWorkbook(memStream, XLEventTracking.Disabled))
{
// Save the workbook to the stream
workbook.Save();
}
// Get the content from the stream
fileContent = memStream.ToArray();
}
if (File.Exists(outFilepath))
{
// Delete existing generated file
File.Delete(outFilepath);
}
using (FileStream fileStream = File.OpenWrite(outFilepath))
{
// Save the new file
fileStream.Write(fileContent, 0, fileContent.Length);
}
}
}
}
```

EDIT: Reformatted the post (CodePlex somehow killed the layout...)
Comments: Thread continued at https://github.com/ClosedXML/ClosedXML/issues/38 . Please try to add 100% reproducible steps to generate this error.

Created Unassigned: Can't set header on non empty header [9500]

$
0
0
I am using this code to set the header on a document that already contains headers(first page and odd even) and it does not work.

pageSetup.Header.Center.AddText("first", XLHFOccurrence.FirstPage);
pageSetup.Header.Center.AddText("odd", XLHFOccurrence.OddPages);
pageSetup.Header.Center.AddText("even", XLHFOccurrence.EvenPages);

if i delete the headers, it does work.

using pageSetup.Header.Center.Clear(); does not work either.
Viewing all 1877 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>