Ejemplo n.º 1
0
# coding=utf-8
import re

import xlrd
import xlwt
from xlutils.copy import copy

from excel.util.log import get_logger
from excel.config.config import Config
import sys
reload(sys)
sys.setdefaultencoding('utf8')

LOG = get_logger(__name__)

class ExcelRead:
    def __init__(self, textBrowser, path):
        self.path = path
        self.textBrowser = textBrowser
        try:
            msg = u"文件路径:%s"%self.path
            LOG.info(msg)
            self.excel = xlrd.open_workbook(self.path)
            self.title_index_dict = dict()  # 记录title名称对应的索引编号
        except Exception as e:
            msg = "打开excel文件失败,文件名称:%s, 原因:%s" % (self.path, e)
            raise Exception(msg)

    def get_excel_obj(self):
        """ 获取excel表对象
Ejemplo n.º 2
0
import os
import string
import threading
from excel.util.log import get_logger
import re
import random
import sys

reload(sys)
import json

sys.setdefaultencoding('utf8')

path = r"C:\Users\xjchenaf\PycharmProjects\ExcelTools\config.ini"

LOG = get_logger(file.__name__)


def dealPath(pathname=''):
    '''deal with windows file path'''
    if pathname:
        pathname = pathname.strip()
    if pathname:
        pathname = r'%s' % pathname
        pathname = string.replace(pathname, r'/', '\\')
        pathname = os.path.abspath(pathname)
        if pathname.find(":\\") == -1:
            pathname = os.path.join(os.getcwd(), pathname)
    return pathname