Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6381135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:21:27+00:00 2026-05-25T02:21:27+00:00

Im generating an Excel 2010 report based on a template in code using Microsoft.Office.Interop.Excel;

  • 0

Im generating an Excel 2010 report based on a template in code using Microsoft.Office.Interop.Excel;

I need to grab the formatting from a cell in the template and apply it on subsequent cells down the column. To simplify, I want my cells to be right justified. Maybe its faster to specify this explicitly in code but I would prefer if I could base formatting on the template and not hardcode a particular style.

I am using workSheet.get_Range("L2", Type.Missing).get_Resize(1, 1) to select the cell.
Any suggestion greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T02:21:28+00:00Added an answer on May 25, 2026 at 2:21 am

    I’m not sure where get_Range() comes into the picture. I usually just get a Range directly.

    I think what you are after is something to this effect (filler code there so you can see the variable names):

    Dim oExcel As Object
    Dim oBook As Excel.Workbook
    Dim oSheet As Excel.Worksheet
    Dim AlignType As Long
    
        oExcel = CreateObject("Excel.Application")
        oBook = oExcel.Workbooks.Open("MySheet.xlsx")
        oSheet = oBook.Worksheets(1)
        AlignType = oSheet.Range("G1").HorizontalAlignment
        oSheet.Range("G1:G" & oSheet.Range("G1").End(Excel.XlDirection.xlDown).Row).HorizontalAlignment = AlignType
    

    Change the ranges to suit your own code.

    Basically, read the value out (it’s an enum, so you don’t need to get the actual setting, just its number), and write it back into the other cells. You could probably do it all in one step, I separated it for clarity.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

we are generating an Excel report and we need to sort the data programmatically
I am programmatically generating Office Documents (in my case Word or Excel 2007) using
I'm currently generating Excel-documents using the Office Object Model. I have a problem with
I need to design a small project for generating excel reports in .NET, which
Has anyone used a Java based library for generating excel documents? Preferably support for
I have an requirement of generating two excel files at once. We are using
We use the jboss seam-->excel module integration for generating excel sheets using e:worksheet. But
I'm generating an .XLS file with a DLL (Excel Library http://code.google.com/p/excellibrary/ ) I've added
I'm using code similar to code mention at http://www.dutch-creatives.com/post/2009/08/11/Export-ListView-to-Excel.aspx to export Listview to excel
I'm generating an Excel worksheet based on entries in a userform. One entry is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.