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

Commented Unassigned: Selecting Table Data/Columns by name. [8959]

$
0
0
Hi there,

Firstly, loving the library! Super-useful coming from the Office libraries!

One issue I had though, is that I'm unable to select a particular column within a table by name. In Excel the table columns are given unique names based on their columns;

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

This lets you select just the cells within that column, and subsequently apply DataValidations to them.

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

Is there a way to mimic this functionality in ClosedXML? I can see the Field type, but it doesn't seem to have any link back to the actual range it refers too, and additionally no way to apply validations.

Something simple like;

```
var workbook = new ClosedXML.Excel.XLWorkbook();
var worksheet = workbook.AddWorksheet("Test");
worksheet.Cell(1,1).Value = "One";
worksheet.Cell(1,2).Value = "Two";
worksheet.Cell(1,3).Value = "Three";
worksheet.Cell(1,4).Value = "Four";
worksheet.Cell(1,5).Value = "Five";

var range = Worksheet.Range(1, 1, 5, 5);
var table = range.CreateTable("New Table");
var field = table.Field("One");

field.DataRange.DataValidations...
field.HeaderCell.


```

Regards,
Jake
Comments: ** Comment from web user: ShadowXVII **

Ah! There it is! I figured it must be possible just couldn't find an [explicit example](https://closedxml.codeplex.com/wikipage?title=Using%20Tables).

Everything else has been really intuitive, which is fantastic. Working in an environment without any .NET smarts or IDE is painful, so I've been relying on documentation :)


Viewing all articles
Browse latest Browse all 1877

Trending Articles



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