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

Commented Unassigned: Bug - Range.CopyTo issue with partly overlapping source and target range [9247]

$
0
0
When a source range spanning multiple rows and columns is copied to a target range which partly overlaps the source range, some resulting cells are blanked out and borders are not formatted.

The issue does not seem to occur when source and target ranges do not overlap.
The issue does not seem to occur when the range spans multiple columns but only one row, at least not for my data range.
Comments: Can you attach an example workbook. Your code references "TestFile" it almost looks like you are copying one range onto cells that maybe merged? Is that possible.[0A][0A]Either way your example workbook will help.

Commented Issue: Implement Subtotals [7862]

$
0
0
I'm not sure how to upload a file, but here's an example. Let me know if that helps. I think, using the examples of formulas and ranges you gave above, I could make it work for the specific spreadsheet I'm working on. The problem is, I'd have to figure out how to do it for each spreadsheet that uses subtotals. I'd like an easy way to define what field to break on and which columns to add or count or whatever for the subtotal.
 
 
Name Date Amount
Joe Blow 2-Mar-2011 50.00
Slim Jim 2-Mar-2011 45.00
Bobby Boy 2-Mar-2011 50.00
2-Mar-2011 Total 145.00
Joe Blow 5-Mar-2011 30.00
Bobby Boy 5-Mar-2011 25.00
5-Mar-2011 Total 55.00
Someone Else 7-Mar-2011 50.00
Still Another 7-Mar-2011 25.00
7-Mar-2011 Total 75.00
Grand Total 275.00
Comments: Right now nothing, we have outlines and the ability to resolve formulas. The API can look like the following:[0A][0A]range.AddSubtotal([0A] atEachChangeIn, // String[0A] useFunction, // Enum[0A] replaceCurrentSubtotals, // optional Boolean[0A] pageBreakBetweenGroups, // optional Boolean[0A] summaryBelowData // optional Boolean[0A])[0A]// It would return an object with the following two methods:[0A].ToColumn( String / Integer ) // Column name or column number[0A].ToColumns( String[] / Integer[] ) // Columns to add the subtotal to[0A][0A]What do you think?

Created Unassigned: IXLColumn.AdjustToContents doesn't work correctly on a HighDPI display [9371]

$
0
0
When using a HighDPI display, IXLColumn.AdjustToContents doesn't work as expected; it makes the columns too long, probably by the same percentage as currentDPI / 96.

The problem is probably around IXLFontBase.GetWidth().

Commented Unassigned: IXLColumn.AdjustToContents doesn't work correctly on a HighDPI display [9371]

$
0
0
When using a HighDPI display, IXLColumn.AdjustToContents doesn't work as expected; it makes the columns too long, probably by the same percentage as currentDPI / 96.

The problem is probably around IXLFontBase.GetWidth().
Comments: Humor me and create a couple of workbooks with one column and apply adjust to contents: 1) With Excel in a normal resolution pc. 2) With Excel in a high resolution pc. 3) With ClosedXML in a normal resolution pc. 4) With ClosedXML in a high resolution pc. Attach those files and also let me know how each looks on both resolutions. Thanks,

Reviewed: ClosedXML 0.75.0 (Oct 02, 2014)

$
0
0
Rated 5 Stars (out of 5) - Great work, works like a charm! Very easy to understand API, thanks for all your work that you put into it.

Created Unassigned: SetDataType(XLCellValues.Text) for setting Text with numbers does not work [9372]

$
0
0
Thanks for the amazing library. Really appreciate it.

I am using ClosedXML 0.75.0

I looked at the following documentation on how text with numbers can correctly show up in Excel without the error "Number in the cell is formatted as text or preceded by an apostrophe".

Documentation Go Text with numbers are getting converted to numbers, what's up with that?:
https://closedxml.codeplex.com/wikipage?title=Text%20with%20numbers%20are%20getting%20converted%20to%20numbers%2c%20what%27s%20up%20with%20that%3f&referringTitle=Documentation#

I tried all the options but still when the Excel file is opened the cells that have numbers show the error - "Number in the cell is formatted as text or preceded by an apostrophe".

How can I avoid it.

I used following codes but did not work:
sheet1.Cell("B6").SetValue("123").SetDataType(XLCellValues.Text);
sheet1.Cell("B6").Value = "'123"

In my code, I am actually populating the sheet from a DataTable, which has some numbers.
I tried doing this so avoid the error from Excel but in vain.

Option 1:
IXLWorksheet sheet = _workBook.Worksheets.Add(dt);
IXLRange range = sheet.RangeUsed();
range.Style.NumberFormat.Format = "@";
foreach (IXLCell cell in range.Cells())
{
cell.SetDataType(XLCellValues.Text);
}

Option 2:
IXLWorksheet sheet = _workBook.Worksheets.Add(dt.TableName);
IXLTable mainTable = sheet.Cell(1, 1).InsertTable(dt, false);
foreach (IXLRangeColumn col in mainTable.Columns())
col.DataType = XLCellValues.Text;

For cells with numbers, I an still getting the error from Excel - "Number in the cell is formatted as text or preceded by an apostrophe".

Is there a fix this?

I have attached the spreadsheets generated.

Option 1.xlsx is generated by the code shown in Option 1

Thanks for all your help.

Commented Unassigned: SetDataType(XLCellValues.Text) for setting Text with numbers does not work [9372]

$
0
0
Thanks for the amazing library. Really appreciate it.

I am using ClosedXML 0.75.0

I looked at the following documentation on how text with numbers can correctly show up in Excel without the error "Number in the cell is formatted as text or preceded by an apostrophe".

Documentation Go Text with numbers are getting converted to numbers, what's up with that?:
https://closedxml.codeplex.com/wikipage?title=Text%20with%20numbers%20are%20getting%20converted%20to%20numbers%2c%20what%27s%20up%20with%20that%3f&referringTitle=Documentation#

I tried all the options but still when the Excel file is opened the cells that have numbers show the error - "Number in the cell is formatted as text or preceded by an apostrophe".

How can I avoid it.

I used following codes but did not work:
sheet1.Cell("B6").SetValue("123").SetDataType(XLCellValues.Text);
sheet1.Cell("B6").Value = "'123"

In my code, I am actually populating the sheet from a DataTable, which has some numbers.
I tried doing this so avoid the error from Excel but in vain.

Option 1:
IXLWorksheet sheet = _workBook.Worksheets.Add(dt);
IXLRange range = sheet.RangeUsed();
range.Style.NumberFormat.Format = "@";
foreach (IXLCell cell in range.Cells())
{
cell.SetDataType(XLCellValues.Text);
}

Option 2:
IXLWorksheet sheet = _workBook.Worksheets.Add(dt.TableName);
IXLTable mainTable = sheet.Cell(1, 1).InsertTable(dt, false);
foreach (IXLRangeColumn col in mainTable.Columns())
col.DataType = XLCellValues.Text;

For cells with numbers, I an still getting the error from Excel - "Number in the cell is formatted as text or preceded by an apostrophe".

Is there a fix this?

I have attached the spreadsheets generated.

Option 1.xlsx is generated by the code shown in Option 1

Thanks for all your help.

Comments: Optin 2.xlsx is generated from code in Option 2

Commented Unassigned: SetDataType(XLCellValues.Text) for setting Text with numbers does not work [9372]

$
0
0
Thanks for the amazing library. Really appreciate it.

I am using ClosedXML 0.75.0

I looked at the following documentation on how text with numbers can correctly show up in Excel without the error "Number in the cell is formatted as text or preceded by an apostrophe".

Documentation Go Text with numbers are getting converted to numbers, what's up with that?:
https://closedxml.codeplex.com/wikipage?title=Text%20with%20numbers%20are%20getting%20converted%20to%20numbers%2c%20what%27s%20up%20with%20that%3f&referringTitle=Documentation#

I tried all the options but still when the Excel file is opened the cells that have numbers show the error - "Number in the cell is formatted as text or preceded by an apostrophe".

How can I avoid it.

I used following codes but did not work:
sheet1.Cell("B6").SetValue("123").SetDataType(XLCellValues.Text);
sheet1.Cell("B6").Value = "'123"

In my code, I am actually populating the sheet from a DataTable, which has some numbers.
I tried doing this so avoid the error from Excel but in vain.

Option 1:
IXLWorksheet sheet = _workBook.Worksheets.Add(dt);
IXLRange range = sheet.RangeUsed();
range.Style.NumberFormat.Format = "@";
foreach (IXLCell cell in range.Cells())
{
cell.SetDataType(XLCellValues.Text);
}

Option 2:
IXLWorksheet sheet = _workBook.Worksheets.Add(dt.TableName);
IXLTable mainTable = sheet.Cell(1, 1).InsertTable(dt, false);
foreach (IXLRangeColumn col in mainTable.Columns())
col.DataType = XLCellValues.Text;

For cells with numbers, I an still getting the error from Excel - "Number in the cell is formatted as text or preceded by an apostrophe".

Is there a fix this?

I have attached the spreadsheets generated.

Option 1.xlsx is generated by the code shown in Option 1

Thanks for all your help.

Comments: Documentation.xlsx is generated using the tips in ClosedXML documentation: https://closedxml.codeplex.com/wikipage?title=Text%20with%20numbers%20are%20getting%20converted%20to%20numbers%2c%20what%27s%20up%20with%20that%3f&referringTitle=Documentation# The number 123 is generated by: sheet1.Cell("B6").SetValue("123").SetDataType(XLCellValues.Text); The number 678 is generated by: sheet1.Cell("C6").Value = "'678";

New Post: Excel cannot open file because the file format or file extension is not valid.

$
0
0
mcconnelljh wrote:
FYI, once I deployed my app to my production web server everything worked and fell into place so obviously something is up with my local setup. Thx for all your help earlier.
Just so that it's on the record, I'm running into a similar problem except in reverse. It works on my local environment but not on the production environment. If you have any information as to why this happened, it would be appreciated.

New Post: Change header of table

$
0
0
Hello, I am creating a workbook with a worksheet and a table. Afterwards I want to change the title of the header for each column. I have already tried different ways, but when I open the xmls file, excel shows an error message(after pressing repair file it opens). It seems like that other user had also the same problem, but not any these solutions have worked for me. Maybe someone can give me a hint. From my config, I am getting the new header text. Here my code:
var headerRows = myTable.HeadersRow();
for (var i = 1; i <= headerRows.CellCount(); i++)
{
       var newheaderText = config.Columns[i - 1].HeaderText;
       myTable.Field(headerRows.Cell(i).Value.ToString()).Name = newheaderText;
       headerRows.Cell(i).SetValue(newheaderText);
}
myWorkBook.SaveAs(stream);

New Post: Change header of table

$
0
0
It was a bug. Pick up the latest source code.

Thanks.

New Post: ClosedXML source code?

$
0
0
Is there any way to get the ClosedXML source code in a MS Visual Studio solution, so we can compile it ourselves?

BTW: It would be great if ClosedXML generated OpenXML source code.

TIA

New Post: Does ClosedXML support Pivot Tables?

$
0
0
Does ClosedXML support Pivot Tables?

To what extent?


TIA.

New Post: ClosedXML source code?

$
0
0
"Source Code" button on the menu bar?

New Post: Does ClosedXML support Pivot Tables?

$
0
0
"Documentation" button on the menu bar -> Pivot Table Example

Created Unassigned: Exception while reading a cell with datatype number and cell is empty. [9373]

$
0
0
Hi,

I am getting a runtime exception 'Input string was not in a correct format' when I am trying to read a cell of type 'Number' and when its blank in the excel sheet.

Below is the code while writing the excel. Here I m explicitly inserting __blank__ when the value is __zero__ and setting the datatype as XLCellValues.Number.
```
var locationValue = GetLocValue(1);
var cellindex = "A1";
worksheetProposal.Cell(cellindex)
.SetValue(locationValue == 0 ? string.Empty : locationValue.ToString())
.SetDataType(XLCellValues.Number);
```

Below is the code while reading the generated excel. Its throwing an exception when m tring the read the same cell "A1" when its blank.
```var LocationId = worksheet.Cell("A1").Value; // Runtime exception 'Input string was not in a correct format' when its blank.
```

Does anyone came across such scenario? Any solution for this?

Edited Unassigned: Exception while reading a cell with datatype number and cell is empty. [9373]

$
0
0
Hi,

I am getting a runtime exception 'Input string was not in a correct format' when I am trying to read a cell of type 'Number' and when its blank in the excel sheet.

Below is the code while writing the excel. Here I m explicitly inserting __blank__ when the value is __zero__ and setting the datatype as XLCellValues.Number.
```
var locationValue = GetLocValue(1);
var cellindex = "A1";
worksheetProposal.Cell(cellindex)
.SetValue(locationValue == 0 ? string.Empty : locationValue.ToString())
.SetDataType(XLCellValues.Number);
```

Below is the code while reading the generated excel. Its throwing an exception when m tring the read the same cell "A1" when its blank.
```
var LocationId = worksheet.Cell("A1").Value; // Runtime exception 'Input string was not in a correct format' when its blank.

```

Does anyone came across such scenario? Any solution for this?

New Post: Exception while reading a cell with datatype number and cell is empty.

$
0
0
Hi,

I am getting a runtime exception 'Input string was not in a correct format' when I am trying to read a cell of type 'Number' and when its blank in the excel sheet.

Below is the code while writing the excel. Here I m explicitly inserting blank when the value is zero and setting the datatype as XLCellValues.Number.
var locationValue = GetLocValue(1);
var cellindex = "A1";
worksheetProposal.Cell(cellindex)
.SetValue(locationValue  == 0 ? string.Empty : locationValue.ToString())
.SetDataType(XLCellValues.Number);
Below is the code while reading the generated excel. Its throwing an exception when m tring the read the same cell "A1" when its blank.
var LocationId = worksheet.Cell("A1").Value; // Runtime exception 'Input string was not in a correct format' when its blank.
Does anyone came across such scenario? Any solution for this?

Closed Unassigned: Exception while reading a cell with datatype number and cell is empty. [9373]

$
0
0
Hi,

I am getting a runtime exception 'Input string was not in a correct format' when I am trying to read a cell of type 'Number' and when its blank in the excel sheet.

Below is the code while writing the excel. Here I m explicitly inserting __blank__ when the value is __zero__ and setting the datatype as XLCellValues.Number.
```
var locationValue = GetLocValue(1);
var cellindex = "A1";
worksheetProposal.Cell(cellindex)
.SetValue(locationValue == 0 ? string.Empty : locationValue.ToString())
.SetDataType(XLCellValues.Number);
```

Below is the code while reading the generated excel. Its throwing an exception when m tring the read the same cell "A1" when its blank.
```
var LocationId = worksheet.Cell("A1").Value; // Runtime exception 'Input string was not in a correct format' when its blank.

```

Does anyone came across such scenario? Any solution for this?
Comments: That's because you're setting the data type of number to a cell that contains a string. You probably meant to set the cell format/style as number. For that you can use the number format id of 2 (Excel's default). See https://closedxml.codeplex.com/wikipage?title=NumberFormatId%20Lookup%20Table

New Post: Exception while reading a cell with datatype number and cell is empty.

Viewing all 1877 articles
Browse latest View live


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