How to change default font opening CSV in Excel - templates

I'm using Excel 2010 to edit CSV files. Just for aesthetic reasons, I'd like to have it use the Courier New font as the default instead of Calibri. I've found the process to create a book.xlt which becomes the default template for opening a new spreadsheet, but is there any way to create a template that will be referenced/applied when opening an existing CSV file?

Related

How to maintain the appropriate file type (MIME) when moving a documents (pdf, xls) from one library to another

I have a workflow that I created in moving a document from one library to another library and it works fine for word documents, but when moving excel or PDF files, the file is moved, but the filetype seems to be a word file type.
I am using Create Item in creating the item in the new library. There does not seem to be a way to update the file type or mime type using this command.

add macro to excel using python xlswriter with data in original excel

I'm using the following code to add a Macro to Excel. I notice that the data / other WorkSheets from the original Excel had dropped completely but the Macro is showing.
This is the code that I am using:
import xlsxwriter
workbooks = xlsxwriter.Workbook('C:\\Users\\user\Desktop\\test.xlsm')
workbooks.add_vba_project('C:\\Users\\user\\Desktop\\vbaProject.bin')
workbooks.close()
I used the link http://xlsxwriter.readthedocs.io/example_macros.html and it seems to be the same from another page https://redoakstrategic.com/pythonexcelmacro/
I wondered if there is another library that I should use for this?
I tried the following link Use Python to Inject Macros into Spreadsheets it seems that here again the data from the original file is overwritten. Not sure if this is a duplicate or not, or if I missed something rather obvious ?
Thanks
Unfortunately, xlsxwriter can't load information from already existing Excel workbooks; it is only used for making new ones. You are overwriting your old workbook with a blank one that has your macros.
If you need to load information, look into openpyxl. It can be used for creating .xlsm files.
One way around it is to create the macro you want in another Excel so we can execute it to affect the other Excel. Then using win32.com it runs the VBA.
enter code here
#import win32com.client
#xl=win32com.client.Dispatch("Excel.Application")
#xl.Workbooks.Open(Filename="C:\\macro.xlsm",ReadOnly=1)
#xl.Application.Run("macro")
#xl = 0

Workbook gem - how to write the excel to html in a formatted manner?

I am using Workbook gem to preview the excel file without page breaks in my website. Right now, I am successful in extracting the excel file and writing it into html format and display as preview.
The following code extracts and writes the excel to html:
excel_file = Workbook::Book.open "#{file_url}"
excel_file.write_to_html(file_name + ".html")
But this gives me an unformatted html sheet with no rows and columns or any of the existing excel file.
According to murb/workbook documentation, it is said that we can pass the format as a hash within its options.
write_to_html(filename = "#{title}.html", options = {})
So, to achieve the format hash, I tried the following code:
excel_file.template.formats
But this returns a null hash. So, how can i get all the formats from the excel file and write to html? Or at least show the html table with borders for all rows and columns.
The author here. The Workbook gem is mainly built to extract and rerepresent the data in files, and not so much the formatting. In the past I made a few attempts on adding support to maintain formatting when converting, but it is far from complete. Some importers don't even set the formatting hash as you found out, notably the xlsx importer needs work on this.
The HTML was built to simply give a basic preview of the data. It basically returns a html-page with all tables which is by default unformatted, although format-names are used in the classes. There is an option though, if you'd pass style_with_inline_css: true... but then it requires an importer to actually set the format hash properly...
I'm happy to guide you here and there when you want to improve the xlsx importer code to suit your needs and hopefully the workbook gem in general, but it will need serious work if you want more than just some background colours and font properties.

can I get the style of a cell of excel using xlrd

I have an excel (xlsx) file and I am trying to read the style of the template, in order to copy the style to another excel file, using python xlrd, and xlwt library
how can I read the style from a cell?
You can use xlutils.copy in order to be able to copy the style from one sheet to other one.
This question seems to be duplicated. Following Preserving styles using python's xlrd,xlwt, and xlutils.copy

programmatically renaming excel worksheet without API

I am working on a project that does not depend on any MS API for open xml documents manipulation (this not a subject of change).
I need to be able to rename a sheet name in a arbitrary excel file.
Can somebody refer me to a page where all the possible references of a worksheet name are listed.
If your programming environment is Excel VBA, then your macro could:
open the arbitrary file
re-name the worksheet
save the arbitrary file
close the arbitrary file
For example:
Sub Macro1()
Workbooks.Open Filename:="C:\TestFolder\ABC.xls"
Sheets(1).Name = "NewName"
ActiveWorkbook.Save
ActiveWorkbook.Close
End Sub