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

Created Unassigned: cant use closedXML [9484]

$
0
0
hi, i cant use ClosedXml.

I'm using Visual Studio 2015 4.6 .NET framework
i only created a new Windows Forms Application project with visual studio 2015.
i added reference ClosedXML.dll.
i added only a button with this following code:

using ClosedXML.Excel;

namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
var workbook = new XLWorkbook();
}
}
}


the exception is:

An unhandled exception of type 'System.IO.FileNotFoundException' occurred in System.Windows.Forms.dll

Additional information: Could not load file or assembly 'DocumentFormat.OpenXml, Version=2.5.5631.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

how can i fix the error?

thanks!!!.






Commented Unassigned: Syntax Error with VLookUp and/or Concatenate [9174]

$
0
0
Hi,

I've been using ClosedXML to read an Excel file (2010 version), and I get an error while reading the content of a cell containing this formula :

In Excel (french version) :
=RECHERCHEV(CONCATENER(D2;"-";F2;"-";H2;"-";I2;"-";J2;"-";K2);Buy!$A:$S;17;0)

In Visual Studio :
?oSht.Cell(idxRow, 12).FormulaA1
"VLOOKUP(CONCATENATE(D2,"-",F2,"-",H2,"-",I2,"-",J2,"-",K2),Buy!$A:$S,17,0)"

When I try to read the cell value, I get an error.

The error returned is this one : "Syntax Error" with no more comments.

The stack trace is :

à ClosedXML.Excel.CalcEngine.CalcEngine.Throw(String msg)
à ClosedXML.Excel.CalcEngine.CalcEngine.Throw()
à ClosedXML.Excel.CalcEngine.CalcEngine.Parse(String expression)
à ClosedXML.Excel.CalcEngine.ExpressionCache.get_Item(String expression)
à ClosedXML.Excel.CalcEngine.CalcEngine.Evaluate(String expression)
à ClosedXML.Excel.XLWorksheet.Evaluate(String expression)
à ClosedXML.Excel.XLCell.get_Value()

HResult : -2146233088

Is there a known problem with the VLOOKUP function, or CONCATENATE ?

Thanks in advance for your help

Damien
Comments: Does ClosedXML support VLookup formula? Can I read VLOOKUP from an excel workbook using ClosedXML?

New Post: DateTime formatting

$
0
0
How can I get a date column to show date and time?

wb.Worksheets.FirstOrDefault().Column("B").Style.DateFormat.SetFormat("mm/dd/yyyy h:mm");

This format is working only for the date, but for the time it is always showing military time instead of 1-12 for the hours. I also want it to show PM or AM.

What am I doing wrong?

New Post: How to download the generated file?

$
0
0
You'll have to save your workbook as a memorystream and write it to the HttpResponse. Something like this:
using (XLWorkbook wb = new XLWorkbook())
{
    // create your workbook here "MyWorkBook"

    // then send it to the http response...

    Response.Clear();
    Response.Buffer = true;
    Response.Charset = "";
    Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
    Response.AddHeader("content-disposition", "attachment;filename=Report.xlsx");

    using (MemoryStream ms = new MemoryStream())
    {
        MyWorkBook.SaveAs(ms);
        ms.WriteTo(Response.OutputStream);
        Response.Flush();
        Response.End();
    }
}

Commented Unassigned: cant use closedXML [9484]

$
0
0
hi, i cant use ClosedXml.

I'm using Visual Studio 2015 4.6 .NET framework
i only created a new Windows Forms Application project with visual studio 2015.
i added reference ClosedXML.dll.
i added only a button with this following code:

using ClosedXML.Excel;

namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
var workbook = new XLWorkbook();
}
}
}


the exception is:

An unhandled exception of type 'System.IO.FileNotFoundException' occurred in System.Windows.Forms.dll

Additional information: Could not load file or assembly 'DocumentFormat.OpenXml, Version=2.5.5631.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

how can i fix the error?

thanks!!!.





Comments: CLosedXML depends on OpenXML, therefore you need this reference as well. The easiest would be to use the ClosedXML Nuget Package.

Created Unassigned: error saving file with databars [9485]

$
0
0
Hello,
Trying to add conditional formatting to a Range - AddConditionalFormat().Databar(XLColor.Green);
And then SaveAs.
In a range there are number values. In Excel I can add conditional formatting databar with no problems.

Got exception
System.Collections.Generic.KeyNotFoundException
at ClosedXML.Excel.XLCFDataBarConverter.Convert(IXLConditionalFormat cf, Int32 priority, SaveContext context)
at ClosedXML.Excel.XLCFConverters.Convert(IXLConditionalFormat conditionalFormat, Int32 priority, SaveContext context)
at ClosedXML.Excel.XLWorkbook.GenerateWorksheetPartContent(WorksheetPart worksheetPart, XLWorksheet xlWorksheet, SaveContext context)
at ClosedXML.Excel.XLWorkbook.CreateParts(SpreadsheetDocument document)
at ClosedXML.Excel.XLWorkbook.CreatePackage(String filePath, SpreadsheetDocumentType spreadsheetDocumentType)
at ClosedXML.Excel.XLWorkbook.SaveAs(String file)

Created Unassigned: Setting DataType for entire column leads to huge memory consumption [9486]

$
0
0
Hi guys,

Just have found a weird bug:
1. Create a workbook and a worksheet in it.
2. Set data type for entire column to Text.
3. This operation adds around 350Mb (on my x64 machine) to the process memory for EVERY column.

The code sample:
```
var workbook = new XLWorkbook();
var worksheet = workbook.Worksheets.Add("Sample Sheet");
// Adds around 350Mb
worksheet.Column(1).DataType = XLCellValues.Text;
// Adds ANOTHER 350Mb
worksheet.Column(2).DataType = XLCellValues.Text;
```

New Post: Iphone-Ipad cant open genereted files

$
0
0
We are facing the same issue on iPhone while using ClosedXml.

New Post: Excel Data Type

$
0
0
Data type seems doesn't work for Excel. For example, I set value of cell (1,1) as number 1 and its datatype as number below.
ws.Cell(1,1).Value = 1;
ws.Cell(1,1).DataType = XLCellValues.Number;

After excel file is saved and I open it in Excel, the cell is still 'generic' not 'number'.

Did I miss something?

Thank you.

Created Unassigned: Multiple save() causes cell formating to break [9487]

$
0
0
Scenario:

1. Open excel file from file and add DateTime to A1.
2. Call Save() for 50 times.
3. Open file in Excel. I see double instead of datetime.


Each call to Save() adds next entry to <x:numFmts>, <x:fonts>, <x:fills> in stylex.xml
Entries in x:numFmts have numFmtId from 0 to 49 and each one has empty formatCode. This overrides built-in cell formats and causes behavior described above.


New Post: is it possible to set a filter at row 5 in the file excel using this tool?

$
0
0
hello
Is it possible to set a filter at row 5 in the file excel using this tool?
could you help me please because i am wasting time, but a lot, this is my second day working on it

New Post: Streaming large excel files

$
0
0
Hi,
I have been using this library for more than 3 years without any issues. Thank you very much for providing a wonderful library.

I am trying to stream the Excel file contents as it gets generated through Web API. I save the woorkbook using .SaveAs to a memory stream Below is the code which does that
var workbook = new XLWorkbook();
var sheet = workbook.Worksheets.Add("Sheet1");
var rowIndex =1;
var streamLimit = 0;
var buffer = new byte[65536];
 foreach (var rowDatain items)
{
 streamLimit ++;
var headerColIndex =1;
foreach (var column in rowData.Split(','))
                    {
 sheet.Cell(rowIndex, headerColIndex).SetValue(column );
headerColIndex++;
}
rowIndex++;
while(streamLimit ==1000){
var memStream = new MemoryStream();
                        workbook.SaveAs(memStream);
var bytesRead = memStream.Read(buffer, 0, Math.Min(intlEngth, buffer.Length));
                            memStream.Position = 0;
                          
await outputStream.WriteAsync(buffer, 0, bytesRead);
workbook = new XLWorkbook();
sheet = workbook.Worksheets.Add("Sheet1");
}
}
I could stream the first batch without issues, but consequent loops is not published at all. I think this is the issue with the header content in the serialized byte array. Is there a way i could separate out the header, content and the footer in the memory stream so that i could stream accordingly. Some kind of separator i could look for in the byte array??

Thank you very much.

New Post: Feature request: Initial zoom of spreadsheet

$
0
0
I cannot see where this is implemented. The most current version I have is 0.76.0 from Dec 2014. This looks as if it was implemented after that date. Where/how do we get this?

New Post: Feature request: Initial zoom of spreadsheet

$
0
0
Sorry, I did not push my version because I did other changes for my specific needs which are not related to that.
You have everything you need in my last post to make the change yourself.

New Post: Styles.xml numFmts 2 instead of 1

$
0
0
Hello,

I'm facing a problem which a bit wierd:
When I a download my Excel generated by ClosedXML, 9 times on 10 it is ok.
1 time on 10, the design totally messed up.
So, I look closely to the generated file which has the design totally messed up:
The file in the folder "xl" called "styles.xml" has this:
<x:numFmts count="2"><x:numFmt numFmtId="0" formatCode="dd/mm/yyyy" /><x:numFmt numFmtId="1" formatCode="#,##0" /></x:numFmts>
Instead of:
<x:numFmts count="1"><x:numFmt numFmtId="0" formatCode="#,##0" /></x:numFmts>
or:
<x:numFmts count="1"><x:numFmt numFmtId="0" formatCode="dd/mm/yyyy" /></x:numFmts>
When numFmts is at 2 => The design is K.O.

Is someone had the same issue?

As Data, I have some tables and pivot tables.

Thank you for reading.

Created Unassigned: Umlauts in hyperlinks to files don't work [9488]

$
0
0
Trying to add hyperlinks pointing to a file on a network share containing umlauts in the path (e.g. "X:\Pläne\list.xlsx") - yes, I know what should be done to people creating these folders ;)

I use worksheet.Cell(iRow, COL_NUM_LINK).Hyperlink = new XLHyperlink(myLink) and it works fine, except for the umlauts, which are broken.

When I later edit the hyperlink containing "ä" in Excel it has been "converted" to "ä" which to me looks like a UTF-8 encoded text opened with ISO 8859-15/ISO 8859-1

Maybe somebody wants to fix this at one point.

I managed to find a workaround which uses the Excel function HYPERLINK to generate the links:

worksheet.Cell(iRow, COL_NUM_LINK).FormulaA1 = string.Format("=HYPERLINK(\"{0}\"__,__\"{1}\")", myLink, myLinkText) ;

Be aware of the comma separating the two parts of the formula, where one would expect to be semicolon in Excel.

Edited Unassigned: Umlauts in hyperlinks to files don't work [9488]

$
0
0
Trying to add hyperlinks pointing to a file on a network share containing umlauts in the path (e.g. "X:\Pläne\list.xlsx") - yes, I know what should be done to people creating these folders ;)

I use worksheet.Cell(iRow, COL_NUM_LINK).Hyperlink = new XLHyperlink(myLink) and it works fine, except for the umlauts, which are broken.

When I later edit the hyperlink containing "ä" in Excel it has been "converted" to "ä" which to me looks like a UTF-8 encoded text opened with ISO 8859-15/ISO 8859-1

I managed to find a workaround which uses the Excel function HYPERLINK to generate the links:

worksheet.Cell(iRow, COL_NUM_LINK).FormulaA1 = string.Format("=HYPERLINK(\"{0}\",\"{1}\")", myLink, myLinkText) ;

Be aware of the __comma separating the two parts of the formula__, where one would expect to be semicolon in Excel.

Maybe this helps people until this is fixed at some point.

Edited Unassigned: Umlauts in hyperlinks to files don't work [9488]

$
0
0
Trying to add hyperlinks pointing to a file on a network share containing umlauts in the path (e.g. "X:\Pläne\list.xlsx") - yes, I know what should be done to people creating these folders ;)

I use worksheet.Cell(iRow, COL_NUM_LINK).Hyperlink = new XLHyperlink(myLink) and it works fine, except for the umlauts, which are broken.

When I later edit the hyperlink containing "ä" in Excel it has been "converted" to "ä" which to me looks like a UTF-8 encoded text opened with ISO 8859-15/ISO 8859-1

I managed to find a workaround which uses the Excel function HYPERLINK to generate the links:

worksheet.Cell(iRow, COL_NUM_LINK).FormulaA1 = string.Format("=HYPERLINK(\"{0}\",\"{1}\")", myLink, myLinkText) ;

Be aware of the __comma separating the two parts of the formula__, where one coming from Excel would expect to be a semicolon.

Maybe this helps people until this is fixed at some point.

Edited Unassigned: Umlauts in hyperlinks to files have wrong encoding [9488]

$
0
0
Trying to add hyperlinks pointing to a file on a network share containing umlauts in the path (e.g. "X:\Pläne\list.xlsx") - yes, I know what should be done to people creating these folders ;)

I use worksheet.Cell(iRow, COL_NUM_LINK).Hyperlink = new XLHyperlink(myLink) and it works fine, except for the umlauts, which are broken.

When I later edit the hyperlink containing "ä" in Excel it has been "converted" to "ä" which to me looks like a UTF-8 encoded text opened with ISO 8859-15/ISO 8859-1

I managed to find a workaround which uses the Excel function HYPERLINK to generate the links:

worksheet.Cell(iRow, COL_NUM_LINK).FormulaA1 = string.Format("=HYPERLINK(\"{0}\",\"{1}\")", myLink, myLinkText) ;

Be aware of the __comma separating the two parts of the formula__, where one coming from Excel would expect to be a semicolon.

Maybe this helps people until this is fixed at some point.

Created Unassigned: Formula IFERROR not included [9493]

$
0
0
Hi, first of all: Thank you for the ClosedXML-API!

I have a Worksheet with the formula "IFERROR(Auswertung!B113,""""), but I can't get the value.
Is there a possibility to get the cell text without evaluating the formular?
Or could you please integrated the formular in the API.

Thank you
Viewing all 1877 articles
Browse latest View live


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