python tkinter xlsxwriter只写一个文本

问题描述 投票:-1回答:1

函数仅将最后一个文本“ 2. Stiprus”写到文件中。我需要写这两个文本,还有大约30个。

def excel_file(xaxis, yaxis, text):
    workbook = xlsxwriter.Workbook("Emotion_test1.xlsx")
    worksheet1 = workbook.add_worksheet()
    worksheet1.write(xaxis, yaxis, text)

    workbook.close()


excel_file(1, 0, "1. Susidomėjęs")
excel_file(2, 0, "2. Stiprus")
python xlsxwriter
1个回答
0
投票

我发现了这个,但是现在我得到了错误IndexError:元组索引超出范围也许是因为它不在课程中?

def excel_file(self, row, col, *args):

    # The first arg should be the token for all write calls.
    token = args[0]
    # Get the token type.
    token_type = type(token)
    # Check for any user defined type handlers with callback functions.
    if token_type in self.write_handlers:
        write_handler = self.write_handlers[token_type]
        function_return = write_handler(self, row, col, *args)
        # If the return value is None then the callback has returned
        # control to this function and we should continue as
        # normal. Otherwise we return the value to the caller and exit.
        if function_return is None:
            pass
        else:
            return function_return
    # Check for standard Python types, if we haven't returned already.
    if token_type is bool:
        return self.write_boolean(row, col, *args)
© www.soinside.com 2019 - 2024. All rights reserved.