I made a function to create a table with the contents from the DataFrame to the Excel spreadsheet.
def make_table(file: str, df_to_use: pd.DataFrame):
writer = pd.ExcelWriter(file, engine="xlsxwriter", datetime_format='m/d/yyyy')
df_to_use.to_excel(writer, sheet_name='Sheet1', startrow=1, header=False, index=False)
worksheet = writer.sheets['Sheet1']
max_row, max_col = df_to_use.shape
column_settings = []
for header in df_to_use.columns:
column_settings.append({'header': header})
worksheet.add_table(0, 0, max_row, max_col - 1, {'columns': column_settings})
worksheet.set_column(0, max_col - 1, 24)
writer.close()
The problem is that in the new Excel Spreadsheet, the URLs with http:// and https:// are hyperlinked. This was not the case in the old Excel Spreadsheet where I am getting the DataFrame from. Is it possible to, when making a table with the function above, have the URLs not be hyperlinked or not formatted as an URL?
I did try making a workbook with writer.book
and use add_format
function but they do not have an option/format for something like ‘strings_to_urls’ as False.
c0unt is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.