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

Patch Uploaded: #15555

$
0
0

Fabian84 has uploaded a patch.

Description:
New Feature: Conditional Formats did not support StopIfTrue.
Implemented the reading and writing.

Based on Source Code ChangeSet: 79843


Patch Uploaded: #15556

$
0
0

Fabian84 has uploaded a patch.

Description:
Code Issue: Difference between DotNet3.5 and DotNet4 version of ClosedXML library.
Change of DotNet3.5 to be the same as DotNet4.

Based on Source Code ChangeSet: 79843

Patch Uploaded: #15557

$
0
0

Fabian84 has uploaded a patch.

Description:
Exception: During development of my other patches I had a lot of exceptions during saving of the document on this code line.

Based on Source Code ChangeSet: 79843

New Post: IntegerExtension.ToStringLookup not threadsafe?

$
0
0
same error error using parallel.foreach..
The main question is.. is ClosedXML threadsafe? I see a lot of Dictionary instead of ConcurrentDictionary.
Maybe someone from the project team can make a statement..

Created Unassigned: [OpenXML 2.5] Creating a table with no rows corrupts workbook (permitted in ClosedXML) [9161]

$
0
0
_It seems this only applies to OpenXML 2.5. However, v2.5 is shipping with Microsoft products which is super seeds OpenXML 2.0. For future compatibility it would be good to be resolved_

Seems having only a single header row and creating a table in ClosedXML results in a corrupt workbook when opened with Excel 2013.

Excel 2013 handles this in the following ways when creating a new table with only one row of data;

* automatically create a header/data row (Depending on options selected in dialog) to ensure there is more than one row.

![Image](http://i.imgur.com/XztT8dv.png)
![Image](http://i.imgur.com/PftUnsp.png)

* when attempting to delete all rows, a single "empty" data row is retained to comply with the "must have a data row" rule

Commented Issue: InvalidCastException on SaveAs [6719]

$
0
0
System.InvalidCastException was unhandled by user code
Message=Unable to cast object of type 'DocumentFormat.OpenXml.Packaging.SharedStringTablePart' to type 'DocumentFormat.OpenXml.Packaging.WorksheetPart'.
Source=ClosedXML
StackTrace:
at ClosedXML.Excel.XLWorkbook.CreateParts(SpreadsheetDocument document)
at ClosedXML.Excel.XLWorkbook.CreatePackage(String filePath)
at ClosedXML.Excel.XLWorkbook.SaveAs(String file)
 
*
 
I haven't yet debugged ClosedXml, however, I am pretty sure I know where this comes from:
 
Before, we had new XLWorkbook(filename). Now we use a MemoryStream (created using the guideline at http://msdn.microsoft.com/en-us/library/ee945362%28v=office.11%29.aspx#InMemory_UsingMemoryStream). That's the only difference between a successful SaveAs call and a failing one.
 
I suspect it has to do with MemoryStream:
 
http://stackoverflow.com/questions/5842254/excel-and-unreadable-content-when-creating-an-open-xml-spreadsheet-with-memorys
 
or (ADDED):
 
http://amykinsgardiner.blogspot.com/2011/02/trouble-with-openxml-and-memorystreams.html
Comments: ** Comment from web user: stefek99 **

Using hello world and question on how to write to Memory Stream: https://closedxml.codeplex.com/discussions/248214


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

var ms = new MemoryStream();
workbook.SaveAs(ms);
return ms;
```

![Image](http://img34.imageshack.us/img34/57/supt.png)

```
at ClosedXML.Excel.XLWorkbook.CreateParts(SpreadsheetDocument document)
at ClosedXML.Excel.XLWorkbook.CreatePackage(Stream stream, Boolean newStream)
at ClosedXML.Excel.XLWorkbook.SaveAs(Stream stream)
```

New Post: dependency on System.Windows.Form

$
0
0
could this dependency be removed?

Created Unassigned: XLAlignmentHorizontalValues [9164]

$
0
0
Thanks for ClosedXML, It is making my volunteer work much easier. I have an ASP.NET C# web application and I have successfully created an Excel file with ClosedXML. I cannot however format a a cell with XLAlignmentHorizontalValues as it is not defined Do I simply download Microsoft.Office.Tools.Excel.dll and add it into my application? Will it work when hosted on a web server without Office?

Thanks

New Post: Border.InsideBorder OutOfMemoryException

$
0
0
I have a huge worksheet, of around 70000 rows by 20 cells. When I go and format the borders it takes a exception "System.OutOfMemoryExceptio".I use:

worksheet.RangeUsed().Style.Border.OutsideBorder = XLBorderStyleValues.Thin
worksheet.RangeUsed().Style.Border.InsideBorder = XLBorderStyleValues.Thin

If I delete the code to set the border,It work OK. Is there any other way to do this?

New Post: XLAlignmentHorizontalValues

$
0
0
Thanks for ClosedXML, It is making my volunteer work much easier. I have an ASP.NET C# web application and I have successfully created an Excel file with ClosedXML. I cannot however format a a cell with XLAlignmentHorizontalValues as it is not defined Do I simply download Microsoft.Office.Tools.Excel.dll and add it into my application? Will it work when hosted on a web server without Office?

Thanks

Commented Unassigned: XLAlignmentHorizontalValues [9164]

$
0
0
Thanks for ClosedXML, It is making my volunteer work much easier. I have an ASP.NET C# web application and I have successfully created an Excel file with ClosedXML. I cannot however format a a cell with XLAlignmentHorizontalValues as it is not defined Do I simply download Microsoft.Office.Tools.Excel.dll and add it into my application? Will it work when hosted on a web server without Office?

Thanks
Comments: ** Comment from web user: pbuffam **

I moved this to Discussion forum, You can close.

New Post: PivotTable

$
0
0
Hello,
Aren´t pivot tables still not fully supported? I got some pivot table working but the behaviour is more than strange. After hours of investigation my pivot table with aprox. 15k of rows is crashing when workbook is opened (message: Feature removed....).

Pivot table is feeded from dataset and what´s strange the crash does not appear evertime workbook is opened, e.g. when I limit dataset to TOP 20 rows everything works fine, sometimes even 15 rows are not working. I´m getting really crazy because of this.

Can you give me some guide what should I be focused on? ...empty cells, data types in my database?

The code:
'Excel file definition
                Dim wb As XLWorkbook = New XLWorkbook()
                'Get data from dataset
                Dim con = New SqlConnection(ConfigurationManager.ConnectionStrings("IPSdb").ConnectionString)
                con.Open()
                Dim cmd As New SqlCommand
                Dim cmdstring As String = "SELECT Partnumber, Qty, Week, Year, Line, CBID FROM tblEDI"
                cmd.CommandType = CommandType.Text
                Dim objAdp = New SqlDataAdapter(cmdstring, con)
                Dim ds = New DataSet()
                objAdp.Fill(ds, "tblEDI")

                Dim sheet1 = wb.Worksheets.Add("EDI raw data")
                sheet1.Cell(1, 1).InsertTable(ds.Tables("tblEDI"), False, False)
                Dim dataRange = sheet1.RangeUsed

                'Add a new sheet for our pivot table
                Dim sheet2 = wb.Worksheets.Add("PivotTable")

                'Create the pivot table, using the data from the table
                Dim pt = sheet2.PivotTables.AddNew("PivotTable", sheet2.Cell(1, 1), dataRange)

                pt.RowLabels.Add("Partnumber")
                pt.RowLabels.Add("Line")
                pt.RowLabels.Add("CBID")
                pt.ColumnLabels.Add("Year")
                pt.ColumnLabels.Add("Week")
                pt.Values.Add("Qty")

                'Pivot format
                With pt
                    .SortFieldsAtoZ = True
                    .ShowGrandTotalsColumns = False
                    .ShowGrandTotalsRows = False
                    .Theme = XLPivotTableTheme.PivotStyleLight1
                    .Subtotals = XLPivotSubtotals.DoNotShow
                    .Layout = XLPivotLayout.Tabular
                    .PreserveCellFormatting = True
                    .AutofitColumns = True
                End With
               
                'Adjust workbook and save
                For Each ws As IXLWorksheet In wb.Worksheets
                    ws.ShowGridLines = False
                    ws.Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Left
                    ws.Columns.AdjustToContents()
                Next

                'Save Excel file to ExportedFiles
                wb.SaveAs(path & "EDIexport " & Day(Today()) & "." & Month(Today()) & "." & Year(Today()) & ".xlsx")
                fileexists = True

New Post: White Spaces in cells

$
0
0
Hello, I'm exporting some data like in example:
  MySheet.Cell(1, 1).InsertTable(results)
My problem is in some cells that must be filled with only 5 white spaces, but when I check this cells, this cells are empty.

I checked my "result" query and there are some fields with white spaces.

There are any solution?

Thx in advice

New Post: Cells.InsertDataTable Time values are recognized as String

$
0
0
Hi,

I am using the Cells.InsertDataTable functionality wherein I import a dataTable from a query to a particular worksheet in the Excel file.
        public void ClosedXml(DataTable dt, string usertemplate, string exceltab)
            {
            var workbook = new XLWorkbook(usertemplate);
            var worksheet = workbook.Worksheet(exceltab);
           
            worksheet.Cell("A2").InsertData(dt.AsEnumerable());
            workbook.Save();

            }
But when I opened the Excel file, the results were not the ones I expected.

Image

As you can see, columns P and Q contain integers and thus automatically recognized and has formula that is why they are in the right side of the cell. but columns R to W are time values and therefore are recognized only as strings that is why they are on the left side.

In my previous implementation, I use the QueryTables interface of Excel interop wherein I transfer a CSV file coming from a dataTable to Excel that is why all the cells have formula and are on the right side when I opened the Excel file.

But yeah, Excel Automation using the Interop is not recommended for server-side deployment.

Are there any similar ways to do the same using ClosedXML?

Any ideas are appreciated.

Thanks!

Reviewed: ClosedXML 0.69.1 (Dec 24, 2013)

$
0
0
Rated 5 Stars (out of 5) - Finding this project was a life saver. I was using the normal html output for fake 2003 files. I was creating excels that could be up to over half a million lines. The document with formatting was over 130 meg and took 30 minutes to open it up to resave it as 2007. I started to look into OpenXML but even then it took a template and a page or two of code to get it to be decent. With ClosedXML I can do the same thing with 4 lines of code to add my dataset and give the table a style. Thank you very much!

Reviewed: ClosedXML 0.69.1 (Dec 24, 2013)

$
0
0
Rated 5 Stars (out of 5) - Finding this project was a life saver. I was using the normal html output for fake 2003 files. I was creating excels that could be up to over half a million rows. The document with formatting was over 130 meg and took 30 minutes to open it up to resave it as 2007. I started to look into OpenXML but even then it took a template and a page or two of code to get it to be decent. With ClosedXML I can do the same thing with 4 lines of code to add my dataset and give the table a style. Thank you very much!

New Post: How do I send data to excel and then refresh aspx page?

$
0
0
I have a gridview that the user can select rows from to export that data to excel. After they select the rows they want to export they press a button. After I export the data to the spread sheet I want my page to refresh. I rebind my gridview to nothing to clear it out, but my page is not getting refreshed.

Any ideas?

Here is my code to put the datatable that I extracted from the gridview to excel ...
 Dim wb As New ClosedXML.Excel.XLWorkbook()
 wb.Worksheets.Add(dt, dt.TableName.ToString)
 Response.Clear()
 Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
  Response.AddHeader("content-disposition", "attachment;filename=MasterCredReport.xlsx")
  Using memoryStream As New MemoryStream()
          wb.SaveAs(memoryStream)
          memoryStream.WriteTo(Response.OutputStream)
          memoryStream.Close()
  End Using

New Post: How do I send data to excel and then refresh aspx page?

$
0
0
I don't believe that it is possible to return a file to the browser and simultaneously redirect or refresh the web page. Note that the browser is occupied interacting with the user to download the file, so it is not listening for other instructions.

However, if anyone out there knows how to do something like this, I would also appreciate hearing how it can be done.

New Post: Cells.InsertDataTable Time values are recognized as String

$
0
0
If you want to align the values in those columns to the right, choose columns 18 through 23 and do the following
worksheet.Columns(18,23).Style.Alignment.Horizontal = XLAlignmentHorizontalValues.Right;

New Post: How do I send data to excel and then refresh aspx page?

$
0
0
What your saying is that when I do the memoryStream write, the browser is doing the downloading and then prompting the user to either open or save the file and does not come back to finish interacting with my page? So is there a way to write the memorysteam to another browser window or tab?
Viewing all 1877 articles
Browse latest View live


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