Excel output file saving error: 255 characters since it exceeds Excel's limit for URLS

♀尐吖头ヾ 提交于 2019-12-23 06:47:16

问题


I am having an issue where the data is not being saved in excel due to exceeding limit of 255 characters of URL value. I am curious to know the solution to this specific problem for my code. Hope someone could suggest and help:

Below is my piece of xlsxwriter code in python:

import xlsxwriter
from openpyxl import load_workbook

workbook =xlsxwriter.Workbook('Output.xlsx')
worksheet = workbook.add_worksheet()

row = 0
col = 0
data = []

url = "http://ec.europa.eu/environment/ets/ohaDetails.do?returnURL=&languageCode=en&accountID=&registryCode=&buttonAction=all&action=&account.registryCode=&accountType=&identifierInReg=&accountHolder=&primaryAuthRep=&installationIdentifier=&installationName=&accountStatus=&permitIdentifier=&complianceStatus=&mainActivityType=-1&searchType=oha&backList=%3C%C2%A0Back&resultList.currentPageNumber=1007&selectedPeriods="

data.append(url)
worksheet.write_row(row, col, tuple(data))
workbook.close()

Build Result:

UserWarning: Ignoring URL 'http://ec.europa.eu/environment/ets/ohaDetails.do?returnURL=&languageCode=en&accountID=&registryCode=&buttonAction=all&action=&account.registryCode=&accountType=&identifierInReg=&accountHolder=&primaryAuthRep=&installationIdentifier=&installationName=&accountStatus=&permitIdentifier=&complianceStatus=&mainActivityType=-1&searchType=oha&backList=%3C%C2%A0Back&resultList.currentPageNumber=1007&selectedPeriods=' with link or location/anchor > 255 characters since it exceeds Excel's limit for URLS
  force_unicode(url))

回答1:


I am curious to know the solution to this specific problem for my code.

No. This is an Excel limitation. It only allows urls up to 255 characters!



来源:https://stackoverflow.com/questions/54135602/excel-output-file-saving-error-255-characters-since-it-exceeds-excels-limit-fo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!