Link to home
Start Free TrialLog in
Avatar of Tek Info
Tek Info

asked on

Add Title to Output

I would like to modify the attached Script so that a Title is added at the top of the output.xlsx file.
The Titel should be:  "Report"

Thank you.
CSV-to-Excel.ps1
Avatar of tel2
tel2
Flag of New Zealand image

Hi Tek,

What cell should the title be in?  On the left (i.e. A1), some cell in the middle, or what?
Do you want a blank row after it?
Do you care about font, font size, colour, etc?

It's probably most efficient to always provide an attachment containing your desired output, so people can see when they've met your requirements, because described requirements can be ambiguous, so if you can do that now, that would be good, and if you can do it (where appropriate) in the original posts of your future questions, that would be even better.  It should save experts from having to ask, and save them from going down the wrong path.

Thanks.
Avatar of Tek Info
Tek Info

ASKER

Thanks.
Actually please do take a look at my past posts and you will see that I have included several times not only an input file, but a script, and a desired output.
I asked for some assistance, without particulars, since they don't matter with this project.
Hi Tek,

A couple of weeks ago I saw a question from you, and I noticed you had included DesiredOutput.out, which was good to see, and sorry for failing to acknowledge that, but I was trying to ask for consistency in my post above.

However, I see your point, if it doesn't matter exactly where the heading goes.  But if you don't include any desired output, and your written requirements don't specify that it doesn't matter, then some experts like me may feel the need to ask exactly where you want it, so they can get it right first time.  So if it doesn't matter, I suggest you say it doesn't matter to save that kind of expert time, and get a faster answer for you.

Thanks.
Hi Tek,

I don't know PowerShell, but since no one else is answering, after a couple of hours of messing around, I've come up with the following.  I could be wrong but I'm guessing that It doesn't position "Report" quite where you want it, but it seems to meet the requirements that you've provided (i.e. "a Title is added at the top", and later you've said "I asked for some assistance, without particulars, since they don't matter with this project"), and I haven't worked out how to position the title any better.

Insert the following line:
    $worksheet.Cells(1,1) = "Report"
OR this line:
    $worksheet.Range("A1") = "Report"

Doesn't look like a couple of hours of work does it?  That's what happens when I don't know the language, and I can't get it to do what I want.
It could go in several places, e.g. just below line 9, i.e.: $worksheet = $workbook.worksheets.Item(1)

If that doesn't meet the requirements you originally provided, let me know how it's failing to.
Hi again Tek,

Does the addition of the one line supplied above meet your requirements?
Thanks, however since there are headings in the input file it moves the "Report " at the end of the first row, after leaving a blank field.
Instead of perhaps moving the whole line down and then adding the "Report" heading it is moving it to the end of the first line after leaving a blank field.
ASKER CERTIFIED SOLUTION
Avatar of tel2
tel2
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
How did you get on with the above adjustment, Tek?