Closed 0Hughman0 closed 11 months ago
Interesting idea / package! It seems like fairly niche functionality, so my initial reaction is that this makes more sense, at least for now, as a 3rd party library.
FYI, you may look at intercepting the output of the ExcelFormatter
class that pandas uses, it already provides a sort of abstract mapping of the data to excel locations.
https://github.com/pandas-dev/pandas/blob/39cc1d0685481c77115f061d856cc60c1e59c8c2/pandas/io/formats/excel.py#L308
And you've maybe already seen these, but if not, this page from the xlsxwriter
docs might provide some examples of things to support/make easy.
http://xlsxwriter.readthedocs.io/pandas_examples.html
Cheers! Yeah I think that's a fair comment!
Thanks for the suggestion, I'll definitely look into this. It has occurred to me that the logic for where each cell goes is in the codebase somewhere. This could be a better solution, as essentially I'm repeating logic (on where to place header rows etc).
I've seen them, but I've not really thought of wrapping every one, but that is a nice idea. Might help with making the application seem less abstract.
Cheers.
Hi!
Dunno if it's worth giving you an update, but whatever!
The project has come a long way since April. I completely re-implremented the 'excel map', both to simplify it, and also to make use of ExcelFormatter
. Probably more significantly I've added a XLMap.create_chart
method, that can generate complete chart object for both xlsxwriter
and openpyxl
.
E.g.
import random
from xl_link import XLDataFrame
f = XLDataFrame(columns=('X', 'Y1', 'Y2'),
data={'X': range(10),
'Y1': list(random.randrange(0, 10) for _ in range(10)),
'Y2': list(random.randrange(0, 10) for _ in range(10))})
f.set_index('X', inplace=True)
xlmap = f.to_excel(writer, sheet_name='scatter', engine='openpyxl')
scatter_chart = xlmap.create_chart('scatter', x_axis_name='x', y_axis_name='y', title='Scatter Example')
xlmap.sheet.insert_chart('A1', scatter_chart)
xlmap.writer.save()
https://github.com/0Hughman0/xl_link
I'd love to hear what you think.
Appears there hasn't been much activity or community support for this feature in a while so closing. Happy to reopen if there's renewed support
e.g.
The to_excel constructor has all the information needed to create such a map.
This would greatly enhance working with spreadsheet libraries to create graphs etc with exported DataFrames.
For example with xlsxwriter, to create a graph without can look like:
which to me looks pretty ugly and confusing. Instead with this could become:
I actually implemented some subclasses of DataFrame to do this here:
https://github.com/0Hughman0/xl_link
but I've realised this could become a lot more elegant and less buggy by intercepting the positions of cells further upstream.