Like yesterday, I will put some simple example of changing plot properties.
Names, indices, etc of all the plots are accessed in for loop.
Take a look at the below website for other examples of plot control.
import win32com.client
from win32com.client import constants as consts
def main():
xl = win32com.client.gencache.EnsureDispatch("Excel.Application")
xl.Visible = True
ws = xl.ActiveSheet
rng = xl.Range("C2:J20")
nch = ws.ChartObjects().Count
for i in range(1,nch+1):
cobj = ws.ChartObjects(i)
cobj.Left, cobj.Top, cobj.Width, cobj.Height = (rng.Left, rng.Top+(i-1)*rng.Height, rng.Width, rng.Height)
print cobj.Index, cobj.Name, cobj.Left, cobj.Top, cobj.Width, cobj.Height
ax = cobj.Chart.Axes(consts.xlValue, consts.xlPrimary)
ax.MaximumScale = 150
ax.MinimumScale = -50
if __name__ == "__main__":
main()
0 件のコメント:
コメントを投稿