Python论坛  - 讨论区

标题:[python-chinese] 读取excel表格,要看哪些资料?

2007年03月28日 星期三 17:23

jessinio smith jessinio在gmail.com
星期三 三月 28 17:23:14 HKT 2007

±¾ÈËÏë¶ÁÈ¡Ò»¸öexcel±í¸ñÎļþ£¬Ôõô°ì£¬ÇëÖ¸µã

-- 
×¢ÒâÉíÌ壬ÉíÌåÊǸïÃüµÄ±¾Ç®£¡£¡
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070328/12c92dee/attachment.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年03月28日 星期三 19:10

Wei Jiang jiejisheng在gmail.com
星期三 三月 28 19:10:03 HKT 2007

ÕâÊÇÒÔÇ°Ò»¸ö±¨±íÏîĿдµÄ¿â£¬½ö¹©²Î¿¼¡£

import win32com.client
import os
import time

class Excel:
    def __init__(self, filename=None, configuration = None):

        self.xApp = win32com.client.Dispatch('Excel.Application')
        self.Config = configuration

        #start info.
        #reading configuation file
        print "Setting standard font: %s" % self.Config['FONT']
        self.xApp.StandardFont = self.Config['FONT']

        print "Setting standard size: %s" % str(TextSize)
        self.xApp.StandardFontSize = TextSize

        #check configuration file
        if os.path.exists( self.Config['DATAPATH'] ) :
            pass
        else:
            print "Error: The given data path doesn't exist"
            self.close()

        # name of report
        if filename:
            self.Filename = filename
            try:
                self.xBook = self.xApp.Workbooks.Open(filename)
            except:
                print "Error: Open file %s failed" % filename
        else:

            self.xBook = self.xApp.Workbooks.Add()
            reportname = self.Config['PROJECT']+ '_R'+ self.Config['VERSION']
+ '_' + time.strftime("%Y%m%d") + '_IssueReport'
            self.Filename = os.path.join( self.Config['PATH'], reportname)
            Name = self.Filename + '.xls'

          # if the file exists, rename new file as format oldname(number)
            try:
                if os.path.exists ( Name ):
                    number = 2

                    # test new name
                    while 1:
                        Name = self.Filename + "(" + str(number) +
").xls"
                        if os.path.exists ( Name ):
                            number += 1
                            continue
                        else :
                            break

                    self.Filename = self.Filename + "(" + str(number) +
").xls"
                    print "Given name has been used, rename new report to
%s" % self.Filename
                else:
                    self.Filename += '.xls'

                print "Report name: %s" % self.Filename
                self.xBook.SaveAs( self.Filename )
                print "Report file was created"
            except:
                print "Error: creating file failed"


    def save(self, newfilename=None):

        print "Saving report to %s" % self.Config['PATH']
        if newfilename:
            self.Filename = newfilename
            self.xBook.SaveAs(newfilename)
        else:
            self.xBook.Save()
        print "Report saved"


    def close(self):
        self.xBook.Close(SaveChanges=0)
        # close error msg
        del self.xApp

    def show(self):
        print "Show generated report"
        self.xApp.Visible = 1

    def delSheet(self, sheet):
        sht = self.xBook.Worksheets(sheet)

        try:
            sht.Delete()
            print "sheet %s is deleted" % sheet
        except:
            print "Error: Delete sheet %s failed" % sheet

    def hide(self):
        self.xApp.Visible = 0

    # get value from cell
    def getCell(self,sheet, row, col):
        "Get value of one cell"
        sht = self.xBook.Worksheets(sheet)
        return sht.Cells(row, col).Value


    # set value for cell
    def setCell(self, sheet,  row, col, value=None, formula=None):

        sht = self.xBook.Worksheets(sheet)
        if formula :
                sht.Cells(row, col).Formula = formula
        else:
                sht.Cells(row, col).Value = value


    # return tuple
    def getRange(self, sheet, row1, col1, row2, col2):
        "return a 2d array (i.e. tuple of tuples)"
        sht = self.xBook.Worksheets(sheet)
        return sht.Range(sht.Cells(row1, col1), sht.Cells(row2, col2)).Value



    # set tuple  for range
    def setRange(self, sheet, topRow, leftCol, data):
        '''
        set range data from a tuple
        '''
        if type( data ) == types.TupleType:

            bottomRow = topRow + len(data) - 1
            rightCol = leftCol + len(data[0]) - 1
            length = len(data)
        else:
            bottomRow = topRow
            rightCol = leftCol
            length = 1
        sht = self.xBook.Worksheets(sheet)

        if( length > MaxAccept):
            times = length/MaxAccept;
            i = 0;
            # Multiple * MaxAccept data
            while( i < times ):

                sht.Range(
                sht.Cells(topRow + i*MaxAccept, leftCol),
                sht.Cells(topRow + (i+1)*MaxAccept - 1, rightCol)
                ).Value = data[i*MaxAccept: (i+1)*MaxAccept]

                i += 1

            # additional data besides Multiple MaxAccept
            sht.Range(
                sht.Cells(topRow + times * MaxAccept, leftCol),
                sht.Cells(bottomRow, rightCol)
                ).Value = data[times * MaxAccept:]


        else:
            sht.Range(
                sht.Cells(topRow, leftCol),
                sht.Cells(bottomRow, rightCol)
                ).Value = data



    # rename a work sheet
    def setSheetName(self, sheet, name):
        '''
        Rename a sheet
        '''
        sht = self.xBook.Worksheets(sheet)

        #logging
        print "Rename sheet %s to %s" % ( sheet , name )
        sht.Name = name
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070328/c1310b1a/attachment-0001.htm 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年03月28日 星期三 19:30

jessinio smith jessinio在gmail.com
星期三 三月 28 19:30:33 HKT 2007

ÎÒÊÇÔÚlinux϶ÁÈ¡excelÎļþµÄ£¬Õâ¶Î´úÂë¿É·ñ£¿£¿


On 3/28/07, Wei Jiang <jiejisheng在gmail.com> wrote:
>
> ÕâÊÇÒÔÇ°Ò»¸ö±¨±íÏîĿдµÄ¿â£¬½ö¹©²Î¿¼¡£
>
> import win32com.client
> import os
> import time
>
> class Excel:
>     def __init__(self, filename=None, configuration = None):
>
>         self.xApp = win32com.client.Dispatch('Excel.Application ')
>         self.Config = configuration
>
>         #start info.
>         #reading configuation file
>         print "Setting standard font: %s" % self.Config['FONT']
>         self.xApp.StandardFont = self.Config['FONT']
>
>         print "Setting standard size: %s" % str(TextSize)
>         self.xApp.StandardFontSize = TextSize
>
>         #check configuration file
>         if os.path.exists( self.Config['DATAPATH'] ) :
>             pass
>         else:
>             print "Error: The given data path doesn't exist"
>             self.close()
>
>         # name of report
>         if filename:
>             self.Filename = filename
>             try:
>                 self.xBook = self.xApp.Workbooks.Open(filename)
>             except:
>                 print "Error: Open file %s failed" % filename
>         else:
>
>             self.xBook = self.xApp.Workbooks.Add()
>             reportname = self.Config['PROJECT']+ '_R'+ self.Config['VERSION']
> + '_' + time.strftime("%Y%m%d") + '_IssueReport'
>             self.Filename = os.path.join( self.Config['PATH'], reportname)
>             Name = self.Filename + '.xls'
>
>           # if the file exists, rename new file as format oldname(number)
>             try:
>                 if os.path.exists ( Name ):
>                     number = 2
>
>                     # test new name
>                     while 1:
>                         Name = self.Filename + "(" + str(number) +
> ").xls"
>                         if os.path.exists ( Name ):
>                             number += 1
>                             continue
>                         else :
>                             break
>
>                     self.Filename = self.Filename + "(" + str(number) +
> ").xls"
>                     print "Given name has been used, rename new report to
> %s" % self.Filename
>                 else:
>                     self.Filename += '.xls'
>
>                 print "Report name: %s" % self.Filename
>                 self.xBook.SaveAs( self.Filename )
>                 print "Report file was created"
>             except:
>                 print "Error: creating file failed"
>
>
>     def save(self, newfilename=None):
>
>         print "Saving report to %s" % self.Config['PATH']
>         if newfilename:
>             self.Filename = newfilename
>             self.xBook.SaveAs(newfilename)
>         else:
>             self.xBook.Save()
>         print "Report saved"
>
>
>     def close(self):
>         self.xBook.Close(SaveChanges=0)
>         # close error msg
>         del self.xApp
>
>     def show(self):
>         print "Show generated report"
>         self.xApp.Visible = 1
>
>     def delSheet(self, sheet):
>         sht = self.xBook.Worksheets(sheet)
>
>         try:
>             sht.Delete()
>             print "sheet %s is deleted" % sheet
>         except:
>             print "Error: Delete sheet %s failed" % sheet
>
>     def hide(self):
>         self.xApp.Visible = 0
>
>     # get value from cell
>     def getCell(self,sheet, row, col):
>         "Get value of one cell"
>         sht = self.xBook.Worksheets(sheet)
>         return sht.Cells (row, col).Value
>
>
>     # set value for cell
>     def setCell(self, sheet,  row, col, value=None, formula=None):
>
>         sht = self.xBook.Worksheets(sheet)
>         if formula :
>                 sht.Cells(row, col).Formula = formula
>         else:
>                 sht.Cells(row, col).Value = value
>
>
>     # return tuple
>     def getRange(self, sheet, row1, col1, row2, col2):
>         "return a 2d array ( i.e. tuple of tuples)"
>         sht = self.xBook.Worksheets(sheet)
>         return sht.Range(sht.Cells(row1, col1), sht.Cells(row2,
> col2)).Value
>
>
>
>     # set tuple  for range
>     def setRange(self, sheet, topRow, leftCol, data):
>         '''
>         set range data from a tuple
>         '''
>         if type( data ) == types.TupleType:
>
>             bottomRow = topRow + len(data) - 1
>             rightCol = leftCol + len(data[0]) - 1
>             length = len(data)
>         else:
>             bottomRow = topRow
>             rightCol = leftCol
>             length = 1
>         sht = self.xBook.Worksheets(sheet)
>
>         if( length > MaxAccept):
>             times = length/MaxAccept;
>             i = 0;
>             # Multiple * MaxAccept data
>             while( i < times ):
>
>                 sht.Range(
>                 sht.Cells (topRow + i*MaxAccept, leftCol),
>                 sht.Cells(topRow + (i+1)*MaxAccept - 1, rightCol)
>                 ).Value = data[i*MaxAccept: (i+1)*MaxAccept]
>
>                 i += 1
>
>             # additional data besides Multiple MaxAccept
>             sht.Range(
>                 sht.Cells(topRow + times * MaxAccept, leftCol),
>                 sht.Cells(bottomRow, rightCol)
>                 ).Value = data[times * MaxAccept:]
>
>
>         else:
>             sht.Range(
>                 sht.Cells(topRow, leftCol),
>                 sht.Cells(bottomRow, rightCol)
>                 ).Value = data
>
>
>
>     # rename a work sheet
>     def setSheetName(self, sheet, name):
>         '''
>         Rename a sheet
>         '''
>         sht = self.xBook.Worksheets(sheet)
>
>         #logging
>         print "Rename sheet %s to %s" % ( sheet , name )
>         sht.Name = name
>
>
> _______________________________________________
> 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
>



-- 
×¢ÒâÉíÌ壬ÉíÌåÊǸïÃüµÄ±¾Ç®£¡£¡
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070328/c660adf3/attachment-0001.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年03月28日 星期三 19:39

Wei Jiang jiejisheng在gmail.com
星期三 三月 28 19:39:25 HKT 2007

ÄÇÓ¦¸Ã²»ÐУ¬ÕâÊÇͨ¹ýcomµÄ£¬ÐèÒªpywinÄ£¿é

On 3/28/07, jessinio smith <jessinio在gmail.com> wrote:
>
> ÎÒÊÇÔÚlinux϶ÁÈ¡excelÎļþµÄ£¬Õâ¶Î´úÂë¿É·ñ£¿£¿
>
>
> On 3/28/07, Wei Jiang <jiejisheng在gmail.com> wrote:
>
> > ÕâÊÇÒÔÇ°Ò»¸ö±¨±íÏîĿдµÄ¿â£¬½ö¹©²Î¿¼¡£
> >
> > import win32com.client
> > import os
> > import time
> >
> > class Excel:
> >     def __init__(self, filename=None, configuration = None):
> >
> >         self.xApp = win32com.client.Dispatch(' Excel.Application ')
> >         self.Config = configuration
> >
> >         #start info.
> >         #reading configuation file
> >         print "Setting standard font: %s" % self.Config['FONT']
> >         self.xApp.StandardFont = self.Config['FONT']
> >
> >         print "Setting standard size: %s" % str(TextSize)
> >         self.xApp.StandardFontSize = TextSize
> >
> >         #check configuration file
> >         if os.path.exists( self.Config['DATAPATH'] ) :
> >             pass
> >         else:
> >             print "Error: The given data path doesn't exist"
> >             self.close()
> >
> >         # name of report
> >         if filename:
> >             self.Filename = filename
> >             try:
> >                 self.xBook = self.xApp.Workbooks.Open(filename)
> >             except:
> >                 print "Error: Open file %s failed" % filename
> >         else:
> >
> >             self.xBook = self.xApp.Workbooks.Add()
> >             reportname = self.Config['PROJECT']+ '_R'+ self.Config['VERSION']
> > + '_' + time.strftime("%Y%m%d") + '_IssueReport'
> >             self.Filename = os.path.join( self.Config['PATH'],
> > reportname)
> >             Name = self.Filename + '.xls'
> >
> >           # if the file exists, rename new file as format
> > oldname(number)
> >             try:
> >                 if os.path.exists ( Name ):
> >                     number = 2
> >
> >                     # test new name
> >                     while 1:
> >                         Name = self.Filename + "(" + str(number) +
> > ").xls"
> >                         if os.path.exists ( Name ):
> >                             number += 1
> >                             continue
> >                         else :
> >                             break
> >
> >                     self.Filename = self.Filename + "(" + str(number) +
> > ").xls"
> >                     print "Given name has been used, rename new report
> > to %s" % self.Filename
> >                 else:
> >                     self.Filename += '.xls'
> >
> >                 print "Report name: %s" % self.Filename
> >                 self.xBook.SaveAs( self.Filename )
> >                 print "Report file was created"
> >             except:
> >                 print "Error: creating file failed"
> >
> >
> >     def save(self, newfilename=None):
> >
> >         print "Saving report to %s" % self.Config['PATH']
> >         if newfilename:
> >             self.Filename = newfilename
> >             self.xBook.SaveAs(newfilename)
> >         else:
> >             self.xBook.Save()
> >         print "Report saved"
> >
> >
> >     def close(self):
> >         self.xBook.Close(SaveChanges=0)
> >         # close error msg
> >         del self.xApp
> >
> >     def show(self):
> >         print "Show generated report"
> >         self.xApp.Visible = 1
> >
> >     def delSheet(self, sheet):
> >         sht = self.xBook.Worksheets(sheet)
> >
> >         try:
> >             sht.Delete()
> >             print "sheet %s is deleted" % sheet
> >         except:
> >             print "Error: Delete sheet %s failed" % sheet
> >
> >     def hide(self):
> >         self.xApp.Visible = 0
> >
> >     # get value from cell
> >     def getCell(self,sheet, row, col):
> >         "Get value of one cell"
> >         sht = self.xBook.Worksheets(sheet)
> >         return sht.Cells (row, col).Value
> >
> >
> >     # set value for cell
> >     def setCell(self, sheet,  row, col, value=None, formula=None):
> >
> >         sht = self.xBook.Worksheets(sheet)
> >         if formula :
> >                 sht.Cells(row, col).Formula = formula
> >         else:
> >                 sht.Cells(row, col).Value = value
> >
> >
> >     # return tuple
> >     def getRange(self, sheet, row1, col1, row2, col2):
> >         "return a 2d array ( i.e. tuple of tuples)"
> >         sht = self.xBook.Worksheets(sheet)
> >         return sht.Range(sht.Cells(row1, col1), sht.Cells(row2,
> > col2)).Value
> >
> >
> >
> >     # set tuple  for range
> >     def setRange(self, sheet, topRow, leftCol, data):
> >         '''
> >         set range data from a tuple
> >         '''
> >         if type( data ) == types.TupleType:
> >
> >             bottomRow = topRow + len(data) - 1
> >             rightCol = leftCol + len(data[0]) - 1
> >             length = len(data)
> >         else:
> >             bottomRow = topRow
> >             rightCol = leftCol
> >             length = 1
> >         sht = self.xBook.Worksheets(sheet)
> >
> >         if( length > MaxAccept):
> >             times = length/MaxAccept;
> >             i = 0;
> >             # Multiple * MaxAccept data
> >             while( i < times ):
> >
> >                 sht.Range(
> >                 sht.Cells (topRow + i*MaxAccept, leftCol),
> >                 sht.Cells(topRow + (i+1)*MaxAccept - 1, rightCol)
> >                 ).Value = data[i*MaxAccept: (i+1)*MaxAccept]
> >
> >                 i += 1
> >
> >             # additional data besides Multiple MaxAccept
> >             sht.Range(
> >                 sht.Cells(topRow + times * MaxAccept, leftCol),
> >                 sht.Cells(bottomRow, rightCol)
> >                 ).Value = data[times * MaxAccept:]
> >
> >
> >         else:
> >             sht.Range(
> >                 sht.Cells(topRow, leftCol),
> >                 sht.Cells(bottomRow, rightCol)
> >                 ).Value = data
> >
> >
> >
> >     # rename a work sheet
> >     def setSheetName(self, sheet, name):
> >         '''
> >         Rename a sheet
> >         '''
> >         sht = self.xBook.Worksheets(sheet)
> >
> >         #logging
> >         print "Rename sheet %s to %s" % ( sheet , name )
> >         sht.Name = name
> >
> >
> > _______________________________________________
> > 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
>
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070328/83ea1ce7/attachment.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年03月28日 星期三 19:57

jessinio smith jessinio在gmail.com
星期三 三月 28 19:57:04 HKT 2007

linuxÏÂÓÐʲôºÃµÄ·½·¨Â𣿣¿

On 3/28/07, Wei Jiang <jiejisheng在gmail.com> wrote:
>
> ÄÇÓ¦¸Ã²»ÐУ¬ÕâÊÇͨ¹ýcomµÄ£¬ÐèÒªpywinÄ£¿é
>
> On 3/28/07, jessinio smith <jessinio在gmail.com> wrote:
> >
> > ÎÒÊÇÔÚlinux϶ÁÈ¡excelÎļþµÄ£¬Õâ¶Î´úÂë¿É·ñ£¿£¿
> >
> >
> > On 3/28/07, Wei Jiang < jiejisheng在gmail.com> wrote:
> >
> > > ÕâÊÇÒÔÇ°Ò»¸ö±¨±íÏîĿдµÄ¿â£¬½ö¹©²Î¿¼¡£
> > >
> > > import win32com.client
> > > import os
> > > import time
> > >
> > > class Excel:
> > >     def __init__(self, filename=None, configuration = None):
> > >
> > >         self.xApp = win32com.client.Dispatch(' Excel.Application ')
> > >         self.Config = configuration
> > >
> > >         #start info.
> > >         #reading configuation file
> > >         print "Setting standard font: %s" % self.Config['FONT']
> > >         self.xApp.StandardFont = self.Config['FONT']
> > >
> > >         print "Setting standard size: %s" % str(TextSize)
> > >         self.xApp.StandardFontSize = TextSize
> > >
> > >         #check configuration file
> > >         if os.path.exists( self.Config['DATAPATH'] ) :
> > >             pass
> > >         else:
> > >             print "Error: The given data path doesn't exist"
> > >             self.close()
> > >
> > >         # name of report
> > >         if filename:
> > >             self.Filename = filename
> > >             try:
> > >                 self.xBook = self.xApp.Workbooks.Open(filename)
> > >             except:
> > >                 print "Error: Open file %s failed" % filename
> > >         else:
> > >
> > >             self.xBook = self.xApp.Workbooks.Add()
> > >             reportname = self.Config['PROJECT']+ '_R'+ self.Config['VERSION']
> > > + '_' + time.strftime("%Y%m%d") + '_IssueReport'
> > >             self.Filename = os.path.join( self.Config['PATH'],
> > > reportname)
> > >             Name = self.Filename + '.xls'
> > >
> > >           # if the file exists, rename new file as format
> > > oldname(number)
> > >             try:
> > >                 if os.path.exists ( Name ):
> > >                     number = 2
> > >
> > >                     # test new name
> > >                     while 1:
> > >                         Name = self.Filename + "(" + str(number) +
> > > ").xls"
> > >                         if os.path.exists ( Name ):
> > >                             number += 1
> > >                             continue
> > >                         else :
> > >                             break
> > >
> > >                     self.Filename = self.Filename + "(" + str(number)
> > > + ").xls"
> > >                     print "Given name has been used, rename new report
> > > to %s" % self.Filename
> > >                 else:
> > >                     self.Filename += '.xls'
> > >
> > >                 print "Report name: %s" % self.Filename
> > >                 self.xBook.SaveAs( self.Filename )
> > >                 print "Report file was created"
> > >             except:
> > >                 print "Error: creating file failed"
> > >
> > >
> > >     def save(self, newfilename=None):
> > >
> > >         print "Saving report to %s" % self.Config['PATH']
> > >         if newfilename:
> > >             self.Filename = newfilename
> > >             self.xBook.SaveAs(newfilename)
> > >         else:
> > >             self.xBook.Save()
> > >         print "Report saved"
> > >
> > >
> > >     def close(self):
> > >         self.xBook.Close(SaveChanges=0)
> > >         # close error msg
> > >         del self.xApp
> > >
> > >     def show(self):
> > >         print "Show generated report"
> > >         self.xApp.Visible = 1
> > >
> > >     def delSheet(self, sheet):
> > >         sht = self.xBook.Worksheets(sheet)
> > >
> > >         try:
> > >             sht.Delete()
> > >             print "sheet %s is deleted" % sheet
> > >         except:
> > >             print "Error: Delete sheet %s failed" % sheet
> > >
> > >     def hide(self):
> > >         self.xApp.Visible = 0
> > >
> > >     # get value from cell
> > >     def getCell(self,sheet, row, col):
> > >         "Get value of one cell"
> > >         sht = self.xBook.Worksheets(sheet)
> > >         return sht.Cells (row, col).Value
> > >
> > >
> > >     # set value for cell
> > >     def setCell(self, sheet,  row, col, value=None, formula=None):
> > >
> > >         sht = self.xBook.Worksheets(sheet)
> > >         if formula :
> > >                 sht.Cells(row, col).Formula = formula
> > >         else:
> > >                 sht.Cells(row, col).Value = value
> > >
> > >
> > >     # return tuple
> > >     def getRange(self, sheet, row1, col1, row2, col2):
> > >         "return a 2d array ( i.e. tuple of tuples)"
> > >         sht = self.xBook.Worksheets(sheet)
> > >         return sht.Range(sht.Cells(row1, col1), sht.Cells(row2,
> > > col2)).Value
> > >
> > >
> > >
> > >     # set tuple  for range
> > >     def setRange(self, sheet, topRow, leftCol, data):
> > >         '''
> > >         set range data from a tuple
> > >         '''
> > >         if type( data ) == types.TupleType:
> > >
> > >             bottomRow = topRow + len(data) - 1
> > >             rightCol = leftCol + len(data[0]) - 1
> > >             length = len(data)
> > >         else:
> > >             bottomRow = topRow
> > >             rightCol = leftCol
> > >             length = 1
> > >         sht = self.xBook.Worksheets(sheet)
> > >
> > >         if( length > MaxAccept):
> > >             times = length/MaxAccept;
> > >             i = 0;
> > >             # Multiple * MaxAccept data
> > >             while( i < times ):
> > >
> > >                 sht.Range(
> > >                 sht.Cells (topRow + i*MaxAccept, leftCol),
> > >                 sht.Cells(topRow + (i+1)*MaxAccept - 1, rightCol)
> > >                 ).Value = data[i*MaxAccept: (i+1)*MaxAccept]
> > >
> > >                 i += 1
> > >
> > >             # additional data besides Multiple MaxAccept
> > >             sht.Range(
> > >                 sht.Cells(topRow + times * MaxAccept, leftCol),
> > >                 sht.Cells(bottomRow, rightCol)
> > >                 ).Value = data[times * MaxAccept:]
> > >
> > >
> > >         else:
> > >             sht.Range(
> > >                 sht.Cells(topRow, leftCol),
> > >                 sht.Cells(bottomRow, rightCol)
> > >                 ).Value = data
> > >
> > >
> > >
> > >     # rename a work sheet
> > >     def setSheetName(self, sheet, name):
> > >         '''
> > >         Rename a sheet
> > >         '''
> > >         sht = self.xBook.Worksheets(sheet)
> > >
> > >         #logging
> > >         print "Rename sheet %s to %s" % ( sheet , name )
> > >         sht.Name = name
> > >
> > >
> > > _______________________________________________
> > > 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
> >
>
>
> _______________________________________________
> 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
>



-- 
×¢ÒâÉíÌ壬ÉíÌåÊǸïÃüµÄ±¾Ç®£¡£¡
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070328/3651c8d7/attachment-0001.htm 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年03月29日 星期四 08:47

amingsc amingsc在gmail.com
星期四 三月 29 08:47:54 HKT 2007

用这个不错pyExcelerator,所有平台都可以使用

jessinio smith 写道:
> 本人想读取一个excel表格文件,怎么办,请指点
>
> -- 
> 注意身体,身体是革命的本钱!!
> ------------------------------------------------------------------------
>
> _______________________________________________
> python-chinese
> Post: send python-chinese at lists.python.cn
> Subscribe: send subscribe to python-chinese-request at lists.python.cn
> Unsubscribe: send unsubscribe to  python-chinese-request at lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年03月29日 星期四 09:49

haur hekun06在gmail.com
星期四 三月 29 09:49:31 HKT 2007

ÏÂÔØxlrd°üÊÔÊÔ.........
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070329/82372922/attachment.htm 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

2007年03月29日 星期四 10:01

jessinio smith jessinio在gmail.com
星期四 三月 29 10:01:41 HKT 2007

ллÁË

On 3/29/07, haur <hekun06在gmail.com> wrote:
>
> ÏÂÔØxlrd°üÊÔÊÔ.........
>
> _______________________________________________
> 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
>



-- 
×¢ÒâÉíÌ壬ÉíÌåÊǸïÃüµÄ±¾Ç®£¡£¡
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070329/6b8399d8/attachment.html 

[导入自Mailman归档:http://www.zeuux.org/pipermail/zeuux-python]

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2025

    京ICP备05028076号