Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Thu Feb 15, 2024 12:34 pm

Hi,

I'm trying to write some values into these cells using python
Screenshot 2024-02-15 132206.png
Destination value
Screenshot 2024-02-15 132206.png (16.83 KiB) Viewed 1881 times


The file and worksheet are loaded/assigned correctly.

When trying to set the values, it gives me the following error:
Screenshot 2024-02-15 132436.png
Python error
Screenshot 2024-02-15 132436.png (79.59 KiB) Viewed 1881 times


If I try only reading from the worksheet, this is the error:
Screenshot 2024-02-15 133231.png
Screenshot 2024-02-15 133231.png (94.93 KiB) Viewed 1881 times


These are the data (if it matters)
survey_question_realorder, answer
0, 'roran15@gmail.com'
1, '3'
2, '3'
3, 'Investment Bank'
4, 'Digital Assets / Innovation'
6, 'Other crypto- or digital asset'
7, 'Ethereum (Public MainNet)'
8, 'Unrestricted'
9, 'Don\'t know'
10, 'Don\'t know'
11, 'Don\'t know'
12, 'Don\'t know'
13, 'Don\'t know'
14, 'Don\'t know'
18, 'Don\'t know'
19, 'Don\'t know'
20, 'Don\'t know'

Any help is appreciated.

Thanks,
Lucas

lucascmg
 
Posts: 1
Joined: Thu Feb 15, 2024 12:19 pm

Fri Feb 16, 2024 5:52 am

Hello,

Thank you for your inquiry.
Based on your description, I did an initial test using the following code, but it did not reproduce your issue. To help us investigate your issue further, please provide your detailed test code. Thanks in advance.
Code: Select all
from spire.xls import *
from spire.xls.common import *


outputFile = "WriteRichText.xlsx"

workbook = Workbook()
workbook.LoadFromFile("input.xlsx")
input = workbook.Worksheets[0]
survey_question_realorder = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,18,19,20]
answer = ['roran15@gmail.com', '3','3','Investment Bank','Digital Assets / Innovation','Other crypto- or digital asset','Ethereum (Public MainNet)',
          'Unrestricted','Don\'t know','Don\'t know','Don\'t know','Don\'t know','Don\'t know','Don\'t know','Don\'t know','Don\'t know','Don\'t know']

for index in range(len(answer)):
    input.Range['A'+str((index+2))].Value = str(survey_question_realorder[index])
    input.Range["B"+str((index+2))].Text = answer[index]
workbook.SaveToFile(outputFile)

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1651
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.XLS