Comments (6)
Hi @NoralK (CC: @dfinke)
In VBA, the Range.Offset property represents a range that's offset from the specified range.
I see the same exists in ImportExcel for the $RangeCells object.
Try the following for size:
# Define offset range, omitting row 1.
$offsetRange = $RangeCells.Offset(1, 0)
# Reveal the cell addresses to confirm
$offsetRange | Select-Object Address
$RangeCells | Select-Object Address
from importexcel.
@pauljnav Thank you! for that nudge...I was able to come up with this complete solution:
$xlSourcefile = "./theFile.xlsx"
$data = Import-Csv "./SingleColumnOfDataWithHeaderRow.csv"
$data | Export-Excel $xlSourcefile -WorksheetName "theSheet" `
-TableStyle None `
-AutoSize -StartRow 1 -StartColumn 6 `
-TableName "theTable"
$xl = Open-ExcelPackage $xlSourcefile
$ws = $xl.Workbook.Worksheets["theSheet"]
$TableRange = $ws.Tables["theTable"].Address.Address
# Original Range F1:F50
$RangeCells=$ws.cells[$TableRange]
# Define offset range, omitting row 1
# however this gives an extra row that we do not want.
# will product F2:F51
$offsetRange = $RangeCells.Offset(1, 0)
# Need F2:F50 - mash it together
$NewTableRange = "$($offsetRange.Start.Address):$($rangecells.End.Address)"
# Get the cells
$RangeWithoutHeaders = $ws.cells[$NewTableRange]
# Add the named range
# F2:F50
$xl.Workbook.Names.Add("theName", $RangeWithoutHeaders) | Out-Null
# Now I can reference theName[ColumnName] in the entire
# Workbook where theTable[ColumnName] has issues
Close-ExcelPackage $xl
from importexcel.
Sorry @NoralK, I have never tried to that nor have I seen it done. I believe you are the first 🎉
from importexcel.
@dfinke Does this mean you will not look into it?
from importexcel.
@NoralK not for a while. I have other pressing matters.
from importexcel.
Glad Open-ExcelPackage
and the -PassThru
are part of the ImportExcel
. Escape hatch to the underlying object model.
Thanks all!
from importexcel.
Related Issues (20)
- "Header" parameter HOT 1
- Import-Excel reads null values with PowerShell 7.4.0 HOT 5
- import-excel cannot read excel formatted xml HOT 1
- Issue with empty values in generated Excel. HOT 1
- Issue with user-defined number format HOT 5
- Export-Excel's -CellStyleSB switch doesn't seem to parse dimensions.address correctly for use with Set-CellStyle HOT 2
- Can't get 'Close-ExcelPackage' to work properly HOT 5
- Exporting hashtable to new (empty) file doesn't transfer as expected HOT 4
- Exporting with default theme now renders as purple after recent office update? HOT 11
- New-ConditionalText Question HOT 1
- Exporting worksheet to csv while keeping excel formats (where applicable) HOT 9
- Set-ExcelRange -Formula issue HOT 1
- KillExcel fails
- Feature Request: Set the default worksheet when the workbook is opened HOT 3
- Close-ExcelPackage -Show broken on MacOS due to PowerShell issue HOT 1
- Add -Calculate to Open-ExcelPackage and Import-Excel
- Export-Excel -Style work wrong with multiple sheets HOT 4
- Exception calling "Save" with "0" argument(s) HOT 3
- Faulty Hyperlink to web site using OfficeOpenXml.ExcelHyperLink HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from importexcel.