I have 14 SQL queries, set into 14 variables. laxTransactions 1 through 7, and rochTransactions 8 through 14. Right now, I have them all going into a single variable and exported to Excel. All queries output vertically one after the other. However, I would like to place the rochTransactions directly to the right of the laxTransactions for a side-by-side comparison. I'm not understanding how to write that group of queries to a different starting column.
Here's some of the code:
$csv = $laxTransactions1 + $space + $laxTransactions2 + $space + $laxTransactions3 + $space + $laxTransactions4 + $space + $laxTransactions5 + $space + $laxTransactions6 + $space + $laxTransactions7 + $space + $space + $RochTransactions8 + $space + $RochTransactions9 + $space + $RochTransactions10 + $space + $RochTransactions11 + $space + $RochTransactions12 + $space + $RochTransactions13 + $space + $RochTransactions14
$csv | Export-Csv -NoTypeInformation -NoClobber -ErrorAction Ignore -Force -Path "C:\Auto PS Scripts\Transactions\AvgTransactions.csv"
[int]$LinesInFile = 0
$reader = New-Object IO.StreamReader "$filePath\AvgTransactions.csv"
while($reader.ReadLine() -ne $null){ $LinesInFile++ }
[int]$lastLineInFile = [int]$LinesInFile + 1
$objExcel = New-Object -ComObject Excel.Application
$objExcel.Visible = $False
$objExcel.DisplayAlerts = $False
$objWorkBook = $objExcel.Workbooks.Open("$filePath\AvgTransactions.csv")
$workSheet = $objWorkbook.Sheets.Item(1)
I can select and format cell ranges, but I'm not really sure how to tackle writing separate query results to different starting columns. Everything I've ever had to output until now has been straight down the spreadsheet. Not asking that someone else do my job for me, but I've been searching the web for a solution and I'm not finding any examples that are helping me. If someone had a link, or some advice, I'd appreciated it greatly! Thank you.