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 8356615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:14:29+00:00 2026-06-09T10:14:29+00:00

I know that I could fill rows using a source in an array using

  • 0

I know that I could fill rows using a source in an array using Pywin32 like

import win32com.client as win32
excel = win32.gencache.EnsureDispatch('Excel.Application')
excel.Visible = True
wb = excel.Workbooks.Add()
ws = wb.Worksheets('Sheet1')
ws.Range("A4:D4").Value = [i for i in range(1,5)]

But in single column case, When I try this like

ws.Range("A1:A4").Value = [i for i in range(1,5)]

I got four 1 in column ‘A’, but what I wanted is 1, 2, 3, 4 in column ‘A’

Is there similar way to deal with column?

If no, what’s the most efficient way to fill multiple cells once?

  • 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-06-09T10:14:30+00:00Added an answer on June 9, 2026 at 10:14 am

    What you need to do is

    import win32com.client as win32
    excel = win32.gencache.EnsureDispatch('Excel.Application')
    excel.Visible = True
    wb = excel.Workbooks.Add()
    ws = wb.Worksheets('Sheet1')
    ws.Range("A1:A4").Value = [[i] for i in range(1,5)]
    

    What you did before was try to fit [1, 2, 3, 4] into a column. However, when it gets converted to the excel formatting an array is always converted into a row. So when you create a 2D array you create an array of rows which is how excel views a column. So what you want is [[1],[2],[3],[4]]. Which is what the code above generates.

    EDIT: I realize this may not be the best wording in the world. If you don’t get it just ask and I will try to come up with a better explanation.

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

Sidebar

Related Questions

Do you know any stand-alone client or web tool (like grc ) that could
I am curious to know that could it be possible that in the below
i know that you could organize your files according to this structure in svn:
Is there a pexpect equivalent for java? I know that I could replicate the
I am new to CSLA, i just want to know what factors that could
Anyone know of a nice efficient function that could convert, for example: HelloWorld -->
Need to know this so that i could send DTMF and that is going
I want to know that how the details of the viewers could be traced
Is it possible to know if a stream/string contains an input that could match
I have some code that I know could be nicer if it's done in

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.