diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Columns/IXLColumn.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Columns/IXLColumn.cs
index 688b86d..38f6ab6 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/Columns/IXLColumn.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Columns/IXLColumn.cs
@@ -56,7 +56,7 @@
/// e.g. Cells("1"), Cells("1:5"), Cells("1,3:5")
///
/// The column cells to return.
- IXLCells Cells(String cellsInColumn);
+ new IXLCells Cells(String cellsInColumn);
///
/// Returns the specified group of cells.
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Columns/IXLColumns.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Columns/IXLColumns.cs
index 1ec568b..82ef949 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/Columns/IXLColumns.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Columns/IXLColumns.cs
@@ -95,7 +95,7 @@
/// Returns the collection of cells.
///
IXLCells Cells();
-
+
///
/// Returns the collection of cells that have a value.
///
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Columns/XLColumn.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Columns/XLColumn.cs
index 1c2afbc..466d06b 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/Columns/XLColumn.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Columns/XLColumn.cs
@@ -112,7 +112,7 @@
return base.Cell(rowNumber, 1);
}
- public IXLCells Cells(String cellsInColumn)
+ public new IXLCells Cells(String cellsInColumn)
{
var retVal = new XLCells(false, false, false);
var rangePairs = cellsInColumn.Split(',');
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/IXLAddress.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/IXLAddress.cs
index 1ffa72a..6c466dc 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/IXLAddress.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/IXLAddress.cs
@@ -15,5 +15,6 @@
Boolean FixedColumn { get; }
String ToStringRelative();
String ToStringFixed();
+ String ToString(XLReferenceStyle referenceStyle);
}
}
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/IXLRangeBase.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/IXLRangeBase.cs
index 318e268..a892251 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/IXLRangeBase.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/IXLRangeBase.cs
@@ -18,6 +18,8 @@
///
IXLCells Cells();
+ IXLCells Cells(String cells);
+
///
/// Returns the collection of cells that have a value.
///
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/IXLRangeColumn.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/IXLRangeColumn.cs
index 9c1ec7d..096d50d 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/IXLRangeColumn.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/IXLRangeColumn.cs
@@ -19,7 +19,7 @@
/// e.g. Cells("1"), Cells("1:5"), Cells("1:2,4:5")
///
/// The column cells to return.
- IXLCells Cells(String cellsInColumn);
+ new IXLCells Cells(String cellsInColumn);
///
/// Returns the specified group of cells.
///
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/IXLRangeColumns.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/IXLRangeColumns.cs
index 2c4458c..a5ad6a0 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/IXLRangeColumns.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/IXLRangeColumns.cs
@@ -19,17 +19,17 @@
void Add(IXLRangeColumn columRange);
///
- /// Returns the collection of cells in this column.
+ /// Returns the collection of cells.
///
IXLCells Cells();
-
+
///
- /// Returns the collection of cells that have a value in this column.
+ /// Returns the collection of cells that have a value.
///
IXLCells CellsUsed();
///
- /// Returns the collection of cells that have a value in this column.
+ /// Returns the collection of cells that have a value.
///
/// if set to true will return all cells with a value or a style different than the default.
IXLCells CellsUsed(Boolean includeStyles);
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/IXLRangeRow.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/IXLRangeRow.cs
index 12e1806..86ddb4d 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/IXLRangeRow.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/IXLRangeRow.cs
@@ -25,7 +25,7 @@
/// e.g. Cells("1"), Cells("1:5"), Cells("1:2,4:5")
///
/// The row's cells to return.
- IXLCells Cells(String cellsInRow);
+ new IXLCells Cells(String cellsInRow);
///
/// Returns the specified group of cells.
///
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/IXLRangeRows.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/IXLRangeRows.cs
index f39ef9b..388f011 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/IXLRangeRows.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/IXLRangeRows.cs
@@ -21,7 +21,7 @@
/// Returns the collection of cells.
///
IXLCells Cells();
-
+
///
/// Returns the collection of cells that have a value.
///
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/IXLRanges.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/IXLRanges.cs
index a9fac2e..34682f0 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/IXLRanges.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/IXLRanges.cs
@@ -67,6 +67,21 @@
IXLRanges SetValue(T value);
-
+ ///
+ /// Returns the collection of cells.
+ ///
+ IXLCells Cells();
+
+ ///
+ /// Returns the collection of cells that have a value.
+ ///
+ IXLCells CellsUsed();
+
+ ///
+ /// Returns the collection of cells that have a value.
+ ///
+ /// if set to true will return all cells with a value or a style different than the default.
+ IXLCells CellsUsed(Boolean includeStyles);
+
}
}
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/XLRangeBase.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/XLRangeBase.cs
index 5f0372a..26de988 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/XLRangeBase.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/XLRangeBase.cs
@@ -228,6 +228,10 @@
cells.Add(this.RangeAddress);
return (IXLCells)cells;
}
+ public IXLCells Cells(String cells)
+ {
+ return Ranges(cells).Cells();
+ }
public IXLCells CellsUsed()
{
var cells = new XLCells(false, true, false);
@@ -929,7 +933,7 @@
public IXLRange RangeUsed()
{
- return this.Range(this.FirstCellUsed(), this.LastCellUsed());
+ return Worksheet.Range(this.FirstCellUsed(), this.LastCellUsed());
}
public Boolean ShareString
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/XLRangeColumn.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/XLRangeColumn.cs
index 0b01341..1433bb4 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/XLRangeColumn.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/XLRangeColumn.cs
@@ -35,7 +35,7 @@
return Cell(row, 1);
}
- public IXLCells Cells(String cellsInColumn)
+ public new IXLCells Cells(String cellsInColumn)
{
var retVal = new XLCells(false, false, false);
var rangePairs = cellsInColumn.Split(',');
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/XLRangeRow.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/XLRangeRow.cs
index 6817c02..527b46e 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/XLRangeRow.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/XLRangeRow.cs
@@ -70,7 +70,7 @@
return InsertColumnsBefore(numberOfColumns, expandRange).Cells();
}
- public IXLCells Cells(String cellsInRow)
+ public new IXLCells Cells(String cellsInRow)
{
var retVal = new XLCells(false, false, false);
var rangePairs = cellsInRow.Split(',');
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/XLRanges.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/XLRanges.cs
index 483ec66..d9d9f7e 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/XLRanges.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Ranges/XLRanges.cs
@@ -230,6 +230,35 @@
return this;
}
}
-
+
+ public IXLCells Cells()
+ {
+ var cells = new XLCells(false, false, false);
+ foreach (var container in ranges)
+ {
+ cells.Add(container.RangeAddress);
+ }
+ return (IXLCells)cells;
+ }
+
+ public IXLCells CellsUsed()
+ {
+ var cells = new XLCells(false, true, false);
+ foreach (var container in ranges)
+ {
+ cells.Add(container.RangeAddress);
+ }
+ return (IXLCells)cells;
+ }
+
+ public IXLCells CellsUsed(Boolean includeStyles)
+ {
+ var cells = new XLCells(false, true, includeStyles);
+ foreach (var container in ranges)
+ {
+ cells.Add(container.RangeAddress);
+ }
+ return (IXLCells)cells;
+ }
}
}
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Rows/IXLRow.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Rows/IXLRow.cs
index 196dec1..d5ce2cd 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/Rows/IXLRow.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Rows/IXLRow.cs
@@ -138,7 +138,7 @@
/// e.g. Cells("1"), Cells("1:5"), Cells("1,3:5")
///
/// The row's cells to return.
- IXLCells Cells(String cellsInRow);
+ new IXLCells Cells(String cellsInRow);
///
/// Returns the specified group of cells.
///
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Rows/IXLRows.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Rows/IXLRows.cs
index 313c5df..13ae711 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/Rows/IXLRows.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Rows/IXLRows.cs
@@ -95,7 +95,7 @@
/// Returns the collection of cells.
///
IXLCells Cells();
-
+
///
/// Returns the collection of cells that have a value.
///
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/Rows/XLRow.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/Rows/XLRow.cs
index 59dd691..3ffde8c 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/Rows/XLRow.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/Rows/XLRow.cs
@@ -143,7 +143,7 @@
return base.Cell(1, columnLetter);
}
- public IXLCells Cells(String cellsInRow)
+ public new IXLCells Cells(String cellsInRow)
{
var retVal = new XLCells(false, false, false);
var rangePairs = cellsInRow.Split(',');
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/XLAddress.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/XLAddress.cs
index addcc81..1c6482a 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/XLAddress.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/XLAddress.cs
@@ -338,10 +338,10 @@
if (referenceStyle == XLReferenceStyle.A1)
return ColumnLetter + rowNumber.ToStringLookup();
else if (referenceStyle == XLReferenceStyle.R1C1)
- return rowNumber.ToStringLookup() + "," + ColumnLetter;
+ return rowNumber.ToStringLookup() + "," + ColumnNumber;
else
if ((Worksheet as XLWorksheet).Internals.Workbook.ReferenceStyle == XLReferenceStyle.R1C1)
- return rowNumber.ToStringLookup() + "," + ColumnLetter;
+ return rowNumber.ToStringLookup() + "," + ColumnNumber;
else
return ColumnLetter + rowNumber.ToStringLookup();
}
diff --git a/ClosedXML/ClosedXML/ClosedXML/Excel/XLWorkbook_Save.cs b/ClosedXML/ClosedXML/ClosedXML/Excel/XLWorkbook_Save.cs
index 9976e24..6544767 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Excel/XLWorkbook_Save.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Excel/XLWorkbook_Save.cs
@@ -730,13 +730,6 @@
sheetId++;
}
- if (!worksheet.PageSetup.PrintAreas.Any())
- {
- var minCell = worksheet.FirstCellUsed();
- var maxCell = worksheet.LastCellUsed();
- if (minCell != null && maxCell != null)
- worksheet.PageSetup.PrintAreas.Add(minCell.Address.ToString(), maxCell.Address.ToString());
- }
if (worksheet.PageSetup.PrintAreas.Any())
{
DefinedName definedName = new DefinedName() { Name = "_xlnm.Print_Area", LocalSheetId = sheetId};
diff --git a/ClosedXML/ClosedXML/ClosedXML/Extensions.cs b/ClosedXML/ClosedXML/ClosedXML/Extensions.cs
index a02373f..8b5bbe9 100644
--- a/ClosedXML/ClosedXML/ClosedXML/Extensions.cs
+++ b/ClosedXML/ClosedXML/ClosedXML/Extensions.cs
@@ -139,5 +139,7 @@
return intToString[value];
}
}
+
+
}
diff --git a/ClosedXML/ClosedXML/ClosedXML_Sandbox/Program.cs b/ClosedXML/ClosedXML/ClosedXML_Sandbox/Program.cs
index 9beedfa..a9854a6 100644
--- a/ClosedXML/ClosedXML/ClosedXML_Sandbox/Program.cs
+++ b/ClosedXML/ClosedXML/ClosedXML_Sandbox/Program.cs
@@ -16,7 +16,7 @@
{
//var fileName = "DataValidation";
var fileName = "Sandbox";
- //var fileName = "Issue_6706";
+ //var fileName = "Issue_6724";
//var wb = new XLWorkbook(String.Format(@"c:\Excel Files\ForTesting\{0}.xlsx", fileName));
var wb = new XLWorkbook();
//var ws = wb.Worksheets.Add("Sheet1");
@@ -29,14 +29,22 @@
//ws.RangeUsed().CreateChart(4, 4, 22, 12);
+ //workbook.Worksheet("CCR").Column("C").LastCellUsed().Address is: {C29}
+ //workbook.Worksheet("CCR").Column("B").LastCellUsed().Address is : {B25}
+
+ //Now, when i use workbook.Worksheet("CCR").Range("B1:C34").RangeUsed().
+ //The expect is B1:C29.
var ws = wb.Worksheets.Add("Sheet1");
- ws.Cell(1,1).Value = "X";
- ws.Protect()
- .SetInsertRows()
- .SetSelectLockedCells(false);
- wb.SaveAs(String.Format(@"c:\Excel Files\ForTesting\{0}_Saved.xlsx", fileName));
- //Console.ReadKey();
+ ws.Cells("A1:C1").Value = "Initial";
+ ws.Cells("C29,B25").Value = "Final";
+
+
+ Console.WriteLine(ws.Column("C").LastCellUsed().Address.ToString( XLReferenceStyle.A1) );
+ Console.WriteLine(ws.Column("B").LastCellUsed().Address.ToString(XLReferenceStyle.R1C1 ));
+ Console.WriteLine(ws.Range("B1:C34").RangeUsed().RangeAddress.ToString());
+ //wb.SaveAs(String.Format(@"c:\Excel Files\ForTesting\{0}_Saved.xlsx", fileName));
+ Console.ReadKey();
}