开始了。
python环境(anaconda继承环境更傻瓜式一点)
安装openpyxl
conda install openpyxl行(row)列(column)格子(cell)工作表(sheet)
基本操作
进入 jupyter环境
juoyter notebook快速补齐快捷键–Tab
方法1:
sheet2 = workbook.active print(sheet2) cell1 = sheet2["A2"] print(cell1.value)方法2:
cell1 = sheet.cell(row = 1,column = 1)注意回顾一下 tuple(元组,不可更改的集合),list(有序,可重复集合),set(无序,不可重复集合),dist(字典,键值对)
#新建tuple---()小括号 tuple1 = (”a“,”b“,”c“) tuple2 = tuple(list1) tuple3 = tuple("hello world") #新建list----[]中括号 list1 = [”a“,”b“,”c“] #新建set,必须由set函数生成或者{}----{}大括号 set1 = set([”a“,”b“,”c“]) set2 = {”a“,”b“,”c“} #新建字典dist #创建一个空字典 empty_dict = dict() print(empty_dict) #用**kwargs可变参数传入关键字创建字典 a = dict(one=1,two=2,three=3) print(a) #传入可迭代对象 b = dict(zip(['one','two','three'],[1,2,3])) print(list(zip(['one','two','three'],[1,2,3]))) print(b) #传入可迭代对象 c = dict([('one', 1), ('two', 2), ('three', 3)]) print(c) c1 = dict([('one', 1), ('two', 2), ('three', 3),('three', 4),('three', 5)]) print(c1)#如果键有重复,其值为最后重复项的值。 #传入映射对象,字典创建字典 d = dict({'one': 1, 'two': 2, 'three': 3})EXCEL里常用的公式
frozenset({'ISLOGICAL', 'YIELDDISC', 'DAYS360', 'CUBEKPIMEMBER', 'IMSUB', 'MATCH', 'CUBEMEMBER', 'IMSUM', 'ODDFYIELD', 'CUBEMEMBERPROPERTY', 'TRUNC', 'IMEXP', 'DSTDEV', 'CUBEVALUE', 'COS', 'COMBIN', 'SECOND', 'SQRTPI', 'COSH', 'ISNONTEXT', 'MODE', 'QUARTILE', 'DPRODUCT', 'DATEVALUE', 'NORMSDIST', 'DMIN', 'HARMEAN', 'ISERROR', 'LOGINV', 'AVERAGEIFS', 'GAMMALN', 'BETADIST', 'DGET', 'TODAY', 'NEGBINOMDIST', 'ABS', 'AND', 'LN', 'SIGN', 'MAX', 'SUMX2MY2', 'SEARCHB', 'HYPGEOMDIST', 'RIGHTB', 'ODDLPRICE', 'PERCENTRANK', 'DAY', 'RAND', 'DOLLAR', 'BETAINV', 'PHONETIC', 'ODDLYIELD', 'BINOMDIST', 'EDATE', 'TEXT', 'GCD', 'EXP', 'COUPDAYS', 'TBILLYIELD', 'CRITBINOM', 'YIELDMAT', 'DAVERAGE', 'IRR', 'PV', 'SIN', 'RANK', 'NETWORKDAYS', 'ATAN2', 'MROUND', 'GROWTH', 'INFO', 'DSTDEVP', 'COUNTIF', 'LOGNORMDIST', 'FV', 'CUBERANKEDMEMBER', 'PROB', 'IMREAL', 'HEX2BIN', 'SUMXMY2', 'ISNUMBER', 'IMABS', 'GETPIVOTDATA', 'BIN2DEC', 'NOMINAL', 'COUNTBLANK', 'ROMAN', 'MIRR', 'AREAS', 'GESTEP', 'SUMX2PY2', 'DMAX', 'JIS', 'PRICEMAT', 'TTEST', 'DELTA', 'SUBSTITUTE', 'COLUMN', 'EFFECT', 'REPLACE', 'QUOTIENT', 'STDEVP', 'ATANH', 'TIMEVALUE', 'RADIANS', 'BESSELK', 'COUNT', 'PMT', 'IFERROR', 'MDETERM', 'GAMMAINV', 'CELL', 'LEFT', 'NETWORKDAYS.INTL', 'CUBESET', 'MULTINOMIAL', 'DB', 'VARPA', 'IF', 'FINDB', 'CONVERT', 'DURATION', 'MINUTE', 'SYD', 'COUPPCD', 'MIN', 'VAR', 'TRIM', 'DEC2OCT', 'OFFSET', 'ERF', 'RANDBETWEEN', 'MINA', 'FLOOR', 'HLOOKUP', 'AVERAGE', 'VDB', 'IMPOWER', 'DDB', 'RIGHT', 'LOGEST', 'PROPER', 'SINH', 'CHOOSE', 'MDURATION', 'INTRATE', 'PPMT', 'LCM', 'INT', 'NORMDIST', 'LOWER', 'MINVERSE', 'N', 'SMALL', 'REPLACEB', 'CONFIDENCE', 'IMCOS', 'STDEV STDEVA', 'ECMA.CEILING', 'ASINH', 'FISHERINV', 'OCT2DEC', 'INDEX', 'SUMIF', 'AVERAGEIF', 'AMORLINC', 'CORREL', 'ERFC', 'FISHER', 'OCT2HEX', 'TINV', 'PERCENTILE', 'BIN2OCT', 'ISREF', 'WEEKDAY', 'POWER', 'XIRR', 'TAN', 'COUPDAYSNC', 'RECEIVED', 'ACCRINT', 'T', 'KURT', 'MEDIAN', 'IMLOG10', 'POISSON', 'LEFTB', 'LOOKUP', 'COLUMNS', 'INTERCEPT', 'ERROR.TYPE', 'EVEN', 'IMCONJUGATE', 'CEILING', 'VLOOKUP', 'TBILLPRICE', 'IMAGINARY', 'PRICE', 'FREQUENCY', 'CHAR', 'NPV', 'VARP', 'IMARGUMENT', 'COMPLEX', 'SUMIFS', 'ROW', 'HEX2OCT', 'WORKDAY ', 'PRICEDISC', 'CHIINV', 'DATE', 'NOT', 'PI', 'DOLLARDE', 'RATE', 'AMORDEGRC', 'SLOPE', 'ACOSH', 'FIND', 'BESSELY', 'WEIBULL', 'NORMINV', 'ODD', 'IMSQRT', 'TANH', 'SERIESSUM', 'ATAN', 'COUNTA', 'FORECAST', 'FIXED', 'TIME', 'XNPV', 'NOW', 'FDIST', 'VALUE', 'BIN2HEX', 'PRODUCT', 'IMSIN', 'CHITEST', 'STANDARDIZE', 'SKEW', 'SUMSQ', 'COUPNCD', 'MMULT', 'LENB', 'COUNTIFS', 'DEVSQ', 'DSUM', 'EOMONTH', 'ISPMT', 'BESSELJ', 'TRIMMEAN', 'DATEDIF', 'PERMUT', 'ODDFPRICE', 'LOG10', 'VARA', 'EXACT', 'INDIRECT', 'LEN', 'SUMPRODUCT', 'SUBTOTAL', 'DOLLARFR', 'ISEVEN', 'DEC2BIN', 'ISO.CEILING', 'WORKDAY.INTL', 'DISC', 'LARGE', 'RTD', 'FALSE', 'FINV', 'YEAR', 'IMPRODUCT', 'IPMT', 'REPT', 'SUM', 'DEGREES', 'MIDB', 'UPPER', 'MOD', 'ROUNDDOWN', 'CODE', 'DEC2HEX', 'MAXA', 'CUBESETCOUNT', 'COVAR', 'FACTDOUBLE', 'HEX2DEC', 'GEOMEAN', 'ISTEXT', 'ACCRINTM', 'RSQ', 'ISNA', 'AVEDEV', 'LOG', 'TDIST', 'WEEKNUM', 'CLEAN', 'IMLN', 'CHIDIST', 'FTEST', 'PEARSON', 'SQRT', 'DCOUNTA', 'NPER', 'AVERAGEA', 'YEARFRAC', 'OCT2BIN', 'MONTH', 'ZTEST', 'STDEVPA STEYX', 'FACT', 'ASIN', 'IMLOG2', 'SLN', 'BAHTTEXT', 'ROWS', 'SEARCH', 'YIELD', 'COUPDAYBS', 'ASC', 'ACOS', 'FVSCHEDULE', 'ISBLANK', 'TBILLEQ', 'TRUE ADDRESS', 'MID', 'HYPERLINK', 'CUMPRINC', 'DVARP', 'DCOUNT', 'NA', 'TRANSPOSE', 'IMDIV', 'ISERR', 'OR', 'ISODD', 'CUMIPMT', 'EXPONDIST', 'TREND', 'GAMMADIST', 'LINEST', 'HOUR', 'ROUND', 'TYPE', 'BESSELI', 'ROUNDUP', 'CONCATENATE', 'COUPNUM', 'DVAR', 'NORMSINV'})这个也不常用,只是看到了,顺便提一下
PatternFill(fill_type)
GradeientFill()