
| Current Path : /home/cgabriel/20_dev/12_procpy/dataninja/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : //home/cgabriel/20_dev/12_procpy/dataninja/xlsdb.py |
# -*- coding: utf-8 -*-
import os,re,sys
try:
import xlrd,xlwt,xlutils,xlutils.copy,openpyxl
except:
import pip
pip.main(["install","xlrd"])
pip.main(["install","xlwt"])
pip.main(["install","xlutils"])
pip.main(["install","openpyxl"])
import xlrd,xlwt,xlutils,xlutils.copy,openpyxl
#*************************************************************************
class Xlsdb (object):
def __init__ (self,xlsfile):
self.xlsfile = xlsfile
#*************************************************************************
def data (self,sheetname=None):
self.wb = xlrd.open_workbook(self.xlsfile,formatting_info=True)
if not sheetname:
sheetname = self.wb.sheet_names()[0]
self.sheet = self.wb.sheet_by_name(sheetname)
self.colnames = {}
self.cursornr = 0
#*************************************************************************
def next (self):
entry = {}
if self.cursornr >= self.sheet.nrows:
return(None)
entry["__NR__"] = self.cursornr
ccols = 0
while (0 == 0):
if ccols == self.sheet.ncols:
break
cell1 = self.sheet.cell(self.cursornr,ccols)
# cell_xf1 = self.sheet.cell_xf_index(self.cursornr,ccols)
# cell_xf2 = self.wb.xf_list[cell_xf1]
# cell_xf3 = self.wb.colour_map[cell_xf2.background.pattern_colour_index]
# cell_xf4 = self.wb.colour_map[cell_xf2.background.background_colour_index]
# print vars(cell_xf2)
# print vars(cell_xf2.background)
# print self.wb.colour_map
# print cell_xf2
colname = "%04u" % ccols
if colname in self.colnames:
colname = self.colnames[colname]
entry[colname] = cell1.value
ccols = ccols + 1
self.cursornr = self.cursornr + 1
return(entry)
#************************
def insert (....):
....
#************************
def delete (....):
....
#************************
def update (....):
....
#************************
def sort (....):
....
#************************
def select (....):
....