2007年07月01日 星期日 20:52
ÔÚ³õʼ»¯µÄʱºò¾Í·¢Éú´íÎ󣬱¨attribute error£¬Ã»¿´³ö´íÔÚÄÄÀÇë´ó¼ÒÖ¸µã Ô´´úÂëÈçÏ£º #coding=utf-8 from win32com.client import Dispatch class ExcelCls(object): def __init__(self): self.objexcel=Dispatch('Excel.Application') self.excelbooks=self.objexcel.Workbooks.Add() self.worksheet=self.excelbooks.Worksheets(1) self.currentrow=1 def WriteCell(self,x,y,value): self.worksheet.Cells(x,y).Value=value def Close(self): self.excelbooks.Close(SaveChanges=True) self.objexcel.Quit() del self.objexcel del self.excelbooks if __name__=='__main__': obj=ExcelCls() obj.WriteCell(1,1,'µ¥Î»£º') obj.Close() -------------- 下一部分 -------------- Ò»¸öHTML¸½¼þ±»ÒƳý... URL: http://python.cn/pipermail/python-chinese/attachments/20070701/1cb896b3/attachment.html
2007年07月01日 星期日 23:08
我运行没有问题! 不过需要该成u'单位:',要不存的是乱码 obj.WriteCell(1,1,u'单位:') Lee DYER wrote: > 在初始化的时候就发生错误,报attribute error,没看出错在哪里,请大家指点 > 源代码如下: > > > #coding=utf-8 > from win32com.client import Dispatch > > class ExcelCls(object): > def __init__(self): > self.objexcel=Dispatch('Excel.Application') > self.excelbooks=self.objexcel.Workbooks.Add() > self.worksheet=self.excelbooks.Worksheets (1) > self.currentrow=1 > > > def WriteCell(self,x,y,value): > self.worksheet.Cells(x,y).Value=value > > def Close(self): > self.excelbooks.Close(SaveChanges=True) > self.objexcel.Quit() > del self.objexcel > del self.excelbooks > > if __name__=='__main__': > obj=ExcelCls() > obj.WriteCell(1,1,'单位:') > obj.Close() > > > ------------------------------------------------------------------------ > > _______________________________________________ > python-chinese > Post: send python-chinese在lists.python.cn > Subscribe: send subscribe to python-chinese-request在lists.python.cn > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > Detail Info: http://python.cn/mailman/listinfo/python-chinese
2007年07月02日 星期一 00:51
ÓиöpyExcelerator >From: "L.J" <lujiacn在163.com> >Reply-To: python-chinese在lists.python.cn >To: python-chinese在lists.python.cn >Subject: Re: [python-chinese] ÓÃwin32com²Ù×÷excelʧ°Ü >Date: Sun, 01 Jul 2007 23:08:35 +0800 > >æè¿è¡æ²¡æé®é¢? >ä¸è¿éè¦è¯¥æu'åä½ï¼?ï¼è¦ä¸åçæ¯ä¹±ç > >obj.WriteCell(1,1,u'åä½ï¼?) >Lee DYER wrote: > > å¨åå§åçæ¶åå°±åçé误ï¼æ¥attribute errorï¼æ²¡çåºé å¨åªéï¼è¯·å¤§å®¶æç¹ > > 源代码如下: > > > > > > #coding=utf-8 > > from win32com.client import Dispatch > > > > class ExcelCls(object): > > def __init__(self): > > self.objexcel=Dispatch('Excel.Application') > > self.excelbooks=self.objexcel.Workbooks.Add() > > self.worksheet=self.excelbooks.Worksheets (1) > > self.currentrow=1 > > > > > > def WriteCell(self,x,y,value): > > self.worksheet.Cells(x,y).Value=value > > > > def Close(self): > > self.excelbooks.Close(SaveChanges=True) > > self.objexcel.Quit() > > del self.objexcel > > del self.excelbooks > > > > if __name__=='__main__': > > obj=ExcelCls() > > obj.WriteCell(1,1,'åä½ï¼?) > > obj.Close() > > > > > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > python-chinese > > Post: send python-chinese在lists.python.cn > > Subscribe: send subscribe to python-chinese-request在lists.python.cn > > Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn > > Detail Info: http://python.cn/mailman/listinfo/python-chinese > >_______________________________________________ >python-chinese >Post: send python-chinese在lists.python.cn >Subscribe: send subscribe to python-chinese-request在lists.python.cn >Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn >Detail Info: http://python.cn/mailman/listinfo/python-chinese _________________________________________________________________ ÏíÓÃÊÀ½çÉÏ×î´óµÄµç×ÓÓʼþϵͳ¡ª MSN Hotmail¡£ http://www.hotmail.com
Zeuux © 2025
京ICP备05028076号