question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AsDataSet() configuration options: Powershell Notation

See original GitHub issue

Your Example for C#:

var result = reader.AsDataSet(new ExcelDataSetConfiguration() {
	
        ConfigureDataTable = (_) => new ExcelDataTableConfiguration() {
		    UseHeaderRow = true
	
        }
});

My rudimenary Basic snippet in PS5.1:

# ExcelDataTableConfiguration => okay
$dTabCnfObj = New-Object ExcelDataReader.ExcelDataTableConfiguration
$dTabCnfObj.UseHeaderRow = $true

# ExcelDataSetConfiguration => okay
$dSetCnfObj = New-Object ExcelDataReader.ExcelDataSetConfiguration
$dSetCnfObj.UseColumnDataType  = $true
# and now beginns the pain (add ExcelDataTableConfiguration to ExcelDataSetConfiguration):
$dSetCnfObj.ConfigureDataTable = "???? [working Example please]"
# $dSetCnfObj.ConfigureDataTable = $dTabCnfOb  didd not work of course ;-)

How accomplish the Same functionality in Powershell (native or with linq)? Can you translate this snippet to Powershell-Natation, please?

Thank you for any assistance

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
andersnmcommented, Feb 8, 2018

That looks neat. I prefer your approach with the anonymous lambda.

Seems I made more mistakes in my code sample, f.ex the syntax for passing a method is $function:ConfigureDataTableCallback. Apparently I should stop posting untested code samples for a language I’m not familiar with =)

Have updated my original sample with a more complete script - and actually tested now!

Closing, I think we solved this

0reactions
jictchcommented, Feb 8, 2018

No i have the Trick found 😉

$dSetCnfObj = New-Object ExcelDataReader.ExcelDataSetConfiguration
$dSetCnfObj.UseColumnDataType  = $true
$dSetCnfObj.ConfigureDataTable = {
	    $dTabCnfObj = New-Object ExcelDataReader.ExcelDataTableConfiguration
	    $dTabCnfObj.UseHeaderRow = $true
            return $dTabCnfObj # that does the Trick ...
}

This works for me.

Any better Approaches welcome 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

AsDataSet() configuration options UseColumnDataType ...
UseColumnDataType in AsDataSet() configuration options doesn't work if set to False. Even if set to False, the data will be imported with ...
Read more >
DbDataAdapter.Fill Method (System.Data.Common)
NET Framework data provider retrieves schema information for only the first result. Notes to Inheritors. This overload of the Fill(DataSet) method is protected ......
Read more >
SCOMHelper.psm1 1.0
Operations Manager Powershell script to output the effective monitoring configurations for a specified object ID, group, or Computer name. .DESCRIPTION Will ...
Read more >
Google BigQuery v2 API - Class BigQueryClient (3.4.0)
The BigQueryClient class only provides convenience operations built on top of an existing service object. Any more complex operations which are not ...
Read more >
List datasets | AutoML Translation Documentation
List existing datasets. Explore further. For detailed documentation that includes this code sample, see the following: Creating and managing datasets. Code ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found