Direct reading and writing Excel files with Powerbuilder

github下载地址

Writing data

show code

n_tp_excel book
book = Create n_tp_excelbook.createxls( cxls.TYPE_XLS)
//
int logoid
logoid = book.addpicture( "logo.png")
//
fonts
n_tp_xlsfont textfont
textfont = book.addfont( )
textfont.setsize( 8)
textfont.setname( "Arial")n_tp_xlsfont titlefont
titlefont = book.addfont( textfont )
titlefont.setsize( 38)
titlefont.setcolor( cxls.COLOR_GRAY25)n_tp_xlsfont font12,font10
font12 = book.addfont( textfont )
font10 = book.addfont( textfont)
font12.setsize( 12)
font10.setsize( 10)format
n_tp_xlsformat textformat
textformat = book.addformat( )
textformat.setfont( textfont)
textformat.setalignh( cxls.ALIGNH_LEFT)n_tp_xlsformat titleformat
titleformat = book.addformat( )
titleformat.setfont( titlefont)
titleformat.setalignh( cxls.ALIGNH_RIGHT)n_tp_xlsformat companyformat
companyformat = book.addformat( )
companyformat.setfont( font12)n_tp_xlsformat dateformat
dateformat = book.addformat(textformat)
dateformat.setnumformat( book.addcustomnumformat( "[$-409]mmmm\ d\,\ yyyy;@"))n_tp_xlsformat phoneformat
phoneformat = book.addformat(textformat)
phoneformat.setnumformat( book.addcustomnumformat( "[<=9999999]###\-####;\(###\)\ ###\-####"))n_tp_xlsformat borderformat
borderformat = book.addformat(textformat )
borderformat.setborder( cxls.BORDERSTYLE_THIN)
borderformat.setbordercolor( cxls.COLOR_GRAY25)
borderformat.setalignv( cxls.ALIGNV_CENTER)n_tp_xlsformat percentformat
percentformat = book.addformat(borderformat )
percentformat.setnumformat( book.addcustomnumformat( "#%_)"))
percentformat.setalignh( cxls.ALIGNH_RIGHT)n_tp_xlsformat textrightformat
textrightformat = book.addformat( textformat )
textRightFormat.setAlignH(cxls.ALIGNH_RIGHT);
textRightFormat.setAlignV(cxls.ALIGNV_CENTER);n_tp_xlsformat thankformat
thankformat = book.addformat( )
thankFormat.setFont(font10);
thankFormat.setAlignH(cxls.ALIGNH_CENTER);n_tp_xlsformat dollarformat
dollarformat = book.addformat( borderformat )
dollarformat.setnumformat( book.addcustomnumformat( "_($* # ##0.00_);_($* (# ##0.00);_($* -??_);_(@_)"))
//actions
n_tp_xlssheet sheet
sheet = book.addsheet( "Sales Receipt表")sheet.setdisplaygridlines(false)sheet.setCol(1, 1, 36)
sheet.setCol(0, 0, 10)
sheet.setCol(2, 4, 11)sheet.setRow(2, 47.25)
sheet.writeStr(2, 1, "Sales Receipt", titleFormat)
sheet.setMerge(2, 2, 1, 4)
sheet.setPicture(2, 1, logoId,1.0,0,0)sheet.writeStr(4, 0, "Apricot Ltd.", companyFormat)
sheet.writeStr(4, 3, "Date:", textFormat)sheet.writeFormula(4, 4, "TODAY()", dateFormat)sheet.writeStr(5, 3, "Receipt #:", textFormat)sheet.writeNum(5, 4, 652, textFormat)sheet.writeStr(8, 0, "Sold to:", textFormat)
sheet.writeStr(8, 1, "John Smith", textFormat)
sheet.writeStr(9, 1, "Pineapple Ltd.", textFormat)
sheet.writeStr(10, 1, "123 Dreamland Street", textFormat)
sheet.writeStr(11, 1, "Moema, 52674", textFormat)sheet.writeNum(12, 1, 2659872055, phoneFormat)sheet.writeStr(14, 0, "Item #", textFormat)
sheet.writeStr(14, 1, "Description", textFormat)
sheet.writeStr(14, 2, "Qty", textFormat)
sheet.writeStr(14, 3, "Unit Price", textFormat)
sheet.writeStr(14, 4, "Line Total", textFormat)int row,col
string s
for row = 15 to 37sheet.setRow(row, 15)for col = 0 to 2//TODOsheet.writeBlank(row, col, borderFormat)next//TODOsheet.writeBlank(row, 3, dollarFormat)//TODO//s = sprintf('IF(C{1}>0;ABS(C{2}*D{3});"")',row + 1,row + 1,row + 1)s = 'IF(C' +string(row + 1)+ '>0;ABS(C' +string(row + 1)+ '*D' +string(row + 1)+ ');"")'sheet.writeFormula(row, 4, s, dollarFormat)
next sheet.writeStr(38, 3, "Subtotal ", textRightFormat)
sheet.writeStr(39, 3, "Sales Tax ", textRightFormat)
sheet.writeStr(40, 3, "Total ", textRightFormat)
sheet.writeFormula(38, 4, "SUM(E16:E38)", dollarFormat)
sheet.writeNum(39, 4, 0.2, percentFormat)
sheet.writeFormula(40, 4, "E39+E39*E40", dollarFormat)
sheet.setRow(38, 15)
sheet.setRow(39, 15)
sheet.setRow(40, 15)sheet.writeStr(42, 0, "Thank you for your business!", thankFormat)
sheet.setMerge(42, 42, 0, 4)// itemssheet.writeNum(15, 0, 45, borderFormat)
sheet.writeStr(15, 1, "Grapes", borderFormat)
sheet.writeNum(15, 2, 250, borderFormat)
sheet.writeNum(15, 3, 4.5, dollarFormat)sheet.writeNum(16, 0, 12, borderFormat)
sheet.writeStr(16, 1, "Bananas", borderFormat)
sheet.writeNum(16, 2, 480, borderFormat)
sheet.writeNum(16, 3, 1.4, dollarFormat)sheet.writeNum(17, 0, 19, borderFormat)
sheet.writeStr(17, 1, "Apples", borderFormat)
sheet.writeNum(17, 2, 180, borderFormat)
sheet.writeNum(17, 3, 2.8, dollarFormat)book.save("receipt.xls",false)destroy bookMessagebox('','complete!')

reading data

show code

n_tp_excel book
book = Create n_tp_excel
string sout
sout = ''
long row,col,rowlast,collast
int celltype
if book.load( "data.xlsx") Then n_tp_xlssheet sheetsheet = book.getsheet( 2)rowlast = sheet.lastrow( )collast = sheet.lastcol( )for row = 0 to rowlast - 1for col = 0 to collast - 1celltype = sheet.celltype(row,col)sout += "(" + string(row) + "," + string(col) + ") = " if sheet.isformula( row,col /*long col */) Thensout += sheet.readformula( row,col /*long col */) + "[formula]~n"elsechoose case celltypecase cxls.celltype_emptysout += "[empty]~n"case cxls.celltype_numbersout += string(sheet.readnum( row,col /*long col */)) + "[number]~n"case cxls.celltype_datetime /*use dateunpack*/sout += string(sheet.readnum( row,col /*long col */)) + "[date]~n"case cxls.celltype_stringsout += sheet.readstr( row,col /*long col */) + "[string]~n"case cxls.celltype_booleansout += string(sheet.readbool( row,col /*long col */)) + "[boolean]~n"    case cxls.celltype_blanksout += "[blank]~n"case cxls.celltype_errorsout += "[error]~n"end chooseend ifnextnext
end ifmessagebox('reading data',sout)
destroy book

Placing pictures

show code

boolean lb
n_tp_excel book
book = Create n_tp_excel
lb = book.createxls( cxls.TYPE_XLSX)
long id
if lb Thenid = book.addpicture( "1.jpg")if id = -1 Thenmessagebox('','picture not found')returnend ifn_tp_xlssheet sheetsheet = book.addsheet( "sheet1")sheet.setpicture( 10/*long row*/,1 /*long col*/, id/*long pictureid*/,1 /*double scale*/,0 /*long offset_x*/,0 /*long offset_y */)if book.save( "Placing pictures.xlsx",false /*boolean usetempfile */) Thenmessagebox('','complete')end if
end if
destroy book

Writing formulas

show code

n_tp_excel book
book = create n_tp_excel
book.createxls( cxls.type_xlsx)n_tp_xlsformat alFormat
alFormat = book.addFormat()
alFormat.setAlignH(cxls.ALIGNH_LEFT)n_tp_xlsformat arformat
arFormat = book.addFormat()
arFormat.setAlignH(cxls.ALIGNH_RIGHT)n_tp_xlsformat alignDateFormat
alignDateFormat = book.addFormat(alFormat)
alignDateFormat.setNumFormat(cxls.NUMFORMAT_DATE)n_tp_xlsfont linkFont
linkFont = book.addFont()
linkFont.setColor(cxls.COLOR_BLUE)
linkFont.setUnderline(cxls.UNDERLINE_SINGLE)n_tp_xlsformat linkFormat
linkFormat = book.addFormat(alFormat)
linkFormat.setFont(linkFont)n_tp_xlssheet sheet
sheet = book.addSheet("Sheet1")sheet.setCol(0, 0, 27)
sheet.setCol(1, 1, 10)sheet.writeNum(2, 1, 40, alFormat)
sheet.writeNum(3, 1, 30, alFormat)
sheet.writeNum(4, 1, 50, alFormat)sheet.writeStr(6, 0, "SUM(B3:B5) = ", arFormat)
sheet.writeFormula(6, 1, "SUM(B3:B5)", alFormat)
sheet.writeStr(7, 0, "AVERAGE(B3:B5) = ", arFormat)
sheet.writeFormula(7, 1, "AVERAGE(B3:B5)", alFormat)
sheet.writeStr(8, 0, "MAX(B3:B5) = ", arFormat)
sheet.writeFormula(8, 1, "MAX(B3:B5)", alFormat)
sheet.writeStr(9, 0, "MIX(B3:B5) = ", arFormat)
sheet.writeFormula(9, 1, "MIN(B3:B5)", alFormat)
sheet.writeStr(10, 0, "COUNT(B3:B5) = ", arFormat)
sheet.writeFormula(10, 1, "COUNT(B3:B5)", alFormat)sheet.writeStr(12, 0, 'IF(B7 > 100;"large";"small") = ', arFormat)
sheet.writeFormula(12, 1, 'IF(B7 > 100;"large";"small")', alFormat)sheet.writeStr(14, 0, "SQRT(25) = ", arFormat)
sheet.writeFormula(14, 1, "SQRT(25)", alFormat)
sheet.writeStr(15, 0, "RAND() = ", arFormat)
sheet.writeFormula(15, 1, "RAND()", alFormat)
sheet.writeStr(16, 0, "2*PI() = ", arFormat)
sheet.writeFormula(16, 1, "2*PI()", alFormat)sheet.writeStr(18, 0, 'UPPER("libxl") = ', arFormat)
sheet.writeFormula(18, 1, 'UPPER("libxl")', alFormat)
sheet.writeStr(19, 0, 'LEFT("window";3) = ', arFormat)
sheet.writeFormula(19, 1, 'LEFT("window";3)', alFormat)
sheet.writeStr(20, 0, 'LEN("string") = ', arFormat)
sheet.writeFormula(20, 1, 'LEN("string")', alFormat)sheet.writeStr(22, 0, "DATE(2010;3;11) = ", arFormat)
sheet.writeFormula(22, 1, "DATE(2010;3;11)", alignDateFormat)
sheet.writeStr(23, 0, "DAY(B23) = ", arFormat)
sheet.writeFormula(23, 1, "DAY(B23)", alFormat)
sheet.writeStr(24, 0, "MONTH(B23) = ", arFormat)
sheet.writeFormula(24, 1, "MONTH(B23)", alFormat)
sheet.writeStr(25, 0, "YEAR(B23) = ", arFormat)
sheet.writeFormula(25, 1, "YEAR(B23)", alFormat)
sheet.writeStr(26, 0, "DAYS360(B23;TODAY()) = ", arFormat)
sheet.writeFormula(26, 1, "DAYS360(B23;TODAY())", alFormat)sheet.writeStr(28, 0, "B3+100*(2-COS(0)) = ", arFormat)
sheet.writeFormula(28, 1, "B3+100*(2-COS(0))", alFormat)
sheet.writeStr(29, 0, "ISNUMBER(B29) = ", arFormat)
sheet.writeFormula(29, 1, "ISNUMBER(B29)", alFormat)
sheet.writeStr(30, 0, "AND(1;0) = ", arFormat)
sheet.writeFormula(30, 1, "AND(1;0)", alFormat)sheet.writeStr(32, 0, "HYPERLINK() = ", arFormat)
sheet.writeFormula(32, 1, 'HYPERLINK("http://www.libxl.com")', linkFormat)if book.save("formula.xlsx",false) thenmessagebox('','complete')
end if
destroy book

Reading and writing date/time values

show code

n_tp_excel book
book = create n_tp_excel
book.createxls( cxls.type_xlsx)n_tp_xlsformat format1,format2,format3,format4
format1 = book.addFormat()
format1.setNumFormat(cxls.NUMFORMAT_DATE)format2 = book.addFormat()
format2.setNumFormat(cxls.NUMFORMAT_CUSTOM_MDYYYY_HMM)format3 = book.addFormat()
format3.setNumFormat(book.addCustomNumFormat("d mmmm yyyy"))format4 = book.addFormat()
format4.setNumFormat(cxls.NUMFORMAT_CUSTOM_HMM_AM)n_tp_xlssheet sheet
sheet = book.addSheet("Sheet1")sheet.setCol(1, 1, 15)// writingsheet.writeNum(2, 1, book.datePack(2010, 3, 11,0,0,0,0), format1)
sheet.writeNum(3, 1, book.datePack(2010, 3, 11, 10, 25, 55,0), format2)
sheet.writeNum(4, 1, book.datePack(2010, 3, 11,0,0,0,0), format3)
sheet.writeNum(5, 1, book.datePack(2010, 3, 11, 10, 25, 55,0), format4)// readinglong year, month, day , hour, min, sec,msecbook.dateUnpack(sheet.readNum(3, 1), ref year, ref month, ref day, ref hour, ref min, ref sec , ref msec)messagebox('datetime',           "year:"       + string(year) + "~n" + &"month:"    + string(month) +  "~n" + &"day:"        + string(day) +  "~n" + &"hour:"     + string(hour) +  "~n" + &"min:"     + string(min) +  "~n" + &"second:"   + string(sec) +  "~n" + &"msec:"     + string(msec) )   if book.save("datetime.xlsx",false) thenMessagebox('','complete')
end if
destroy book

Access to sheet by name

show code

n_tp_excel book
book = Create n_tp_excellong sheetcount,sheetindex
string sheetname
if book.load( "data.xlsx") Thensheetcount = book.getsheetcount( )for sheetindex = 0 to sheetcount  - 1  sheetname = book.getsheetname( sheetindex)if sheetname = "mysheetname" Then/*get your sheetbyname*//*sheet  = book.getsheet( sheetindex)*/end ifnext
end if

Merging cells

show code

n_tp_excel book
book = create n_tp_excel
book.createxls( cxls.type_xlsx)n_tp_xlsformat format
format = book.addFormat();
format.setAlignH(cxls.ALIGNH_CENTER);
format.setAlignV(cxls.ALIGNV_CENTER);n_tp_xlssheet sheet
sheet = book.addSheet("Sheet1")sheet.writeStr(3, 1, "Hello World !", format)sheet.setMerge(3, 5, 1, 5)sheet.setMerge(7, 20, 1, 2)
sheet.setMerge(7, 20, 4, 5)sheet.writeNum(7, 1, 1, format)
sheet.writeNum(7, 4, 2, format)if book.save( "merge.xlsx"/*string filename*/,false /*boolean usetempfile */) thenmessagebox('','complete')
end if
destroy book

Inserting rows and columns

show code

n_tp_excel book
book = create n_tp_excel
book.createxls( cxls.type_xlsx)n_tp_xlssheet sheet
sheet = book.addSheet("Sheet1")n_tp_xlsformat format
format = book.addformat()long row,col
for row = 1 to 30for col = 0 to 10sheet.writeNum(row, col,rand(10),format)next
nextsheet.insertRow(5, 10,false)
sheet.insertRow(20, 22,false)sheet.insertCol(4, 5,false)
sheet.insertCol(8, 8,false)if book.save( "insert.xlsx"/*string filename*/,false /*boolean usetempfile */) thenmessagebox('','complete')
end if
destroy book

Using number formats

show code

n_tp_excel book
book = create n_tp_excel
book.createxls( cxls.type_xlsx)n_tp_xlssheet sheet
sheet = book.addSheet("my")sheet.setCol(0, 0, 38)
sheet.setCol(1, 1, 10)    // built-in number formats
n_tp_xlsformat format1,format2,format3,format4,format5,format6,format7,format8,format9,format10,format11,format12format1 = book.addFormat()
format1.setNumFormat(cxls.NUMFORMAT_NUMBER_D2)sheet.writeStr(3, 0, "NUMFORMAT_NUMBER_D2")
sheet.writeNum(3, 1, 2.5681, format1)format2 = book.addFormat()
format2.setNumFormat(cxls.NUMFORMAT_NUMBER_SEP)sheet.writeStr(4, 0, "NUMFORMAT_NUMBER_SEP")
sheet.writeNum(4, 1, 2500000, format2)format3 = book.addFormat()
format3.setNumFormat(cxls.NUMFORMAT_CURRENCY_NEGBRA)sheet.writeStr(5, 0, "NUMFORMAT_CURRENCY_NEGBRA")
sheet.writeNum(5, 1, -500, format3)format4 = book.addFormat()
format4.setNumFormat(cxls.NUMFORMAT_PERCENT)sheet.writeStr(6, 0, "NUMFORMAT_PERCENT")
sheet.writeNum(6, 1, -0.25, format4)format5 = book.addFormat()
format5.setNumFormat(cxls.NUMFORMAT_SCIENTIFIC_D2)sheet.writeStr(7, 0, "NUMFORMAT_SCIENTIFIC_D2")
sheet.writeNum(7, 1, 890, format5)format6 = book.addFormat()
format6.setNumFormat(cxls.NUMFORMAT_FRACTION_ONEDIG)sheet.writeStr(8, 0, "NUMFORMAT_FRACTION_ONEDIG")
sheet.writeNum(8, 1, 0.75, format6)format7 = book.addFormat()
format7.setNumFormat(cxls.NUMFORMAT_DATE)sheet.writeStr(9, 0, "NUMFORMAT_DATE")
sheet.writeNum(9, 1, book.datePack(2020, 5, 16,0,0,0,0), format7)format8 = book.addFormat()
format8.setNumFormat(cxls.NUMFORMAT_CUSTOM_MON_YY)sheet.writeStr(10, 0, "NUMFORMAT_CUSTOM_MON_YY")
sheet.writeNum(10, 1, book.datePack(2020, 5, 16,0,0,0,0), format8)// custom number formatsformat9 = book.addFormat()
format9.setNumFormat(book.addCustomNumFormat("#.###"))    sheet.writeStr(12, 0, "#.###")
sheet.writeNum(12, 1, 20.5627, format9)format10 = book.addFormat()
format10.setNumFormat(book.addCustomNumFormat("#.00"))    sheet.writeStr(13, 0, "#.00")
sheet.writeNum(13, 1, 4.8, format10)format11 = book.addFormat()
format11.setNumFormat(book.addCustomNumFormat('0.00 "dollars"'))    sheet.writeStr(14, 0, '0.00 "dollars"')
sheet.writeNum(14, 1, 1.23, format11)format12 = book.addFormat()
format12.setNumFormat(book.addCustomNumFormat("[Red][<=100];[Green][>100]"))    sheet.writeStr(15, 0, "[Red][<=100];[Green][>100]")
sheet.writeNum(15, 1, 60, format12)if book.save( "numformats.xlsx"/*string filename*/,false /*boolean usetempfile */) thenmessagebox('','complete')
end if
destroy book

Aligning, colors and borders

show code

n_tp_excel book
book = create n_tp_excelbook.createxls( cxls.type_xlsx)n_tp_xlssheet sheet
sheet = book.addSheet("my")sheet.setDisplayGridlines(false)sheet.setCol(1, 1, 30)
sheet.setCol(3, 3, 11.4)
sheet.setCol(4, 4, 2)
sheet.setCol(5, 5, 15)
sheet.setCol(6, 6, 2)
sheet.setCol(7, 7, 15.4)string nameAlignH[] = {"ALIGNH_LEFT", "ALIGNH_CENTER", "ALIGNH_RIGHT"}
int alignH[] = {cxls.ALIGNH_LEFT, cxls.ALIGNH_CENTER, cxls.ALIGNH_RIGHT}int ifor i = 1 to upperbound(alignH)n_tp_xlsformat formatformat = book.addFormat()format.setAlignH(alignH[i])format.setBorder(cxls.borderstyle_thin)sheet.writeStr(i * 2 + 2, 1, nameAlignH[i], format)
next  string nameAlignV[] = {"ALIGNV_TOP", "ALIGNV_CENTER", "ALIGNV_BOTTOM"}
long alignV[] = {cxls.ALIGNV_TOP, cxls.ALIGNV_CENTER, cxls.ALIGNV_BOTTOM}for i = 1 to upperbound(alignV)format = book.addFormat()format.setAlignV(alignV[i])format.setBorder(cxls.borderstyle_thin)sheet.writeStr(4, i * 2 + 1, nameAlignV[i], format)sheet.setMerge(4, 8, i * 2 + 1, i * 2 + 1)
nextstring nameBorderStyle[] = {"BORDERSTYLE_MEDIUM", "BORDERSTYLE_DASHED", &"BORDERSTYLE_DOTTED", "BORDERSTYLE_THICK",& "BORDERSTYLE_DOUBLE", "BORDERSTYLE_DASHDOT"}
long borderStyle[] = {cxls.BORDERSTYLE_MEDIUM, cxls.BORDERSTYLE_DASHED,cxls.BORDERSTYLE_DOTTED, &cxls.BORDERSTYLE_THICK, cxls.BORDERSTYLE_DOUBLE, cxls.BORDERSTYLE_DASHDOT}for i = 1 to upperbound(nameBorderStyle)       format = book.addFormat()format.setBorder(borderStyle[i])sheet.writeStr(i * 2 + 12, 1, nameBorderStyle[i], format)
next string nameColors[] = {"COLOR_RED", "COLOR_BLUE", "COLOR_YELLOW", &"COLOR_PINK", "COLOR_GREEN", "COLOR_GRAY25"}
long colors[] = {cxls.COLOR_RED, cxls.COLOR_BLUE, cxls.COLOR_YELLOW, cxls.COLOR_PINK, cxls.COLOR_GREEN, &cxls.COLOR_GRAY25}
long fillPatterns[] = {cxls.FILLPATTERN_GRAY50, cxls.FILLPATTERN_HORSTRIPE, &cxls.FILLPATTERN_VERSTRIPE, cxls.FILLPATTERN_REVDIAGSTRIPE,&cxls.FILLPATTERN_THINVERSTRIPE, cxls.FILLPATTERN_THINHORCROSSHATCH}for i = 1 to upperbound(nameColors)n_tp_xlsformat format1format1 = book.addFormat()format1.setFillPattern(cxls.FILLPATTERN_SOLID)format1.setPatternForegroundColor(colors[i])sheet.writeBlank(i * 2 + 12, 3, format1)n_tp_xlsformat format2format2 = book.addFormat()format2.setFillPattern(fillPatterns[i])format2.setPatternForegroundColor(colors[i])sheet.writeBlank(i * 2 + 12, 5, format2)n_tp_xlsfont fontfont = book.addFont()font.setColor(colors[i])n_tp_xlsformat format3format3 = book.addFormat()format3.setBorder(cxls.borderstyle_thin)format3.setBorderColor(colors[i])        format3.setFont(font)sheet.writeStr(i * 2 + 12, 7, nameColors[i], format3)
nextif book.save("acb.xlsx",false) thenmessagebox('','complete')
end ifdestroy book

Customizing fonts

show code

n_tp_excel book
book = create n_tp_excel
book.createxls( cxls.type_xlsx)n_tp_xlssheet sheet
sheet = book.addSheet("Sheet1")string fonts[] = {"Aria", "Arial Black", "Comic Sans MS", "Courier New",&"Impact", "Times New Roman", "Verdana"}int i
for i = 1 to upperbound(fonts)n_tp_xlsfont fontfont = book.addFont()font.setSize(16)font.setName(fonts[i])n_tp_xlsformat formatformat = book.addFormat()format.setFont(font)sheet.writeStr(i + 1, 3, fonts[i], format)
nextint fontSize[] = {8, 10, 12, 14, 16, 20, 25}for i = 1 to upperbound(fontSize) font = book.addFont()font.setSize(fontSize[i])        format = book.addFormat()format.setFont(font)sheet.writeStr(i + 1, 7, "Text", format)
next  font = book.addFont()
font.setSize(16)
format = book.addFormat()
format.setRotation(255)
format.setFont(font)
sheet.writeStr(2, 9, "Vertica", format)
sheet.setMerge(2, 8, 9, 9)n_tp_xlsfont boldFont
boldFont = book.addFont()
boldFont.setBold(true)
n_tp_xlsformat boldFormat
boldFormat = book.addFormat()
boldFormat.setFont(boldFont)n_tp_xlsfont italicFont
italicFont = book.addFont()
italicFont.setItalic(true)
n_tp_xlsformat italicFormat
italicFormat = book.addFormat()
italicFormat.setFont(italicFont)n_tp_xlsfont underlineFont
underlineFont = book.addFont()
underlineFont.setUnderline(cxls.UNDERLINE_SINGLE)
n_tp_xlsformat underlineFormat
underlineFormat = book.addFormat()
underlineFormat.setFont(underlineFont)n_tp_xlsfont strikeoutFont
strikeoutFont = book.addFont()
strikeoutFont.setStrikeOut(true)
n_tp_xlsformat strikeoutFormat
strikeoutFormat = book.addFormat()
strikeoutFormat.setFont(strikeoutFont)sheet.writeStr(2, 1, "Norma")
sheet.writeStr(3, 1, "Bold", boldFormat)
sheet.writeStr(4, 1, "Italic", italicFormat)
sheet.writeStr(5, 1, "Underline", underlineFormat)
sheet.writeStr(6, 1, "Strikeout", strikeoutFormat)    if book.save("fonts.xlsx",false) Thenmessagebox('','complete')
end ifdestroy book

通过powerbuilder直接读和写Excel文件,支持xlsx,xls,et等格式,不需要安装office excel,WPS等依赖相关推荐

  1. 不安装Office操作Excel文件(.xlsx)

    1.使用场景: 在不安装Office组件包的情况下,操作Excel文件(.xlsx).以前做过的好几个项目中,都需要对Excel文件处理,特别是将统计成果按照一定的格式和样式输出到Excel中,或将固 ...

  2. pandas之数据文件导入和导出(python读取.csv,.txt,excel文件(.xlsx)以及导出为.csv、excel文件)

    文件类型:.csv,.txt,.xlsx .csv文件,一行即为数据表的一行.生成数据表字段用逗号隔开(英文的逗号!!!!).csv文件用记事本和excel都能打开,用记事本打开显示逗号,用excel ...

  3. 使用Python解决对比出两个Excel文件中的不同项并将结果重新写入一个新的Excel文件

    使用Python解决对比出两个Excel文件中的不同项并将结果重新写入一个新的Excel文件 因为有统计成员到会情况的任务,每次汇总时都很麻烦,需要一个个对应腾讯会议导出名单的成员,然后在总表上进行标 ...

  4. python3 根据sql导出excel文件 支持xls和xlsx

    python3 根据sql导出excel文件 支持xls和xlsx 代码简介: sql_output_excel函数是用来导出excel文件的,其他两个函数是导出xls和xlsx格式的. 使用pymy ...

  5. R语言write.xlsx函数将数据写入Excel文件:写入Excel文件并自定义表单的名称、将数据写入Excel文件新的表单(sheet)中、将文件保存为xls文件格式(而不是xlsx)

    R语言write.xlsx函数将数据写入Excel文件:写入Excel文件并自定义表单的名称.将数据写入Excel文件新的表单(sheet)中.将文件保存为xls文件格式(而不是xlsx) 目录

  6. Python使用pandas读取两个或者多个excel文件(xlsx)并进行数据连接(join)合并两个或者多个excel的信息

    Python使用pandas读取两个或者多个excel文件(xlsx)并进行数据连接(join)合并两个或者多个excel的信息 目录

  7. 如何删除写保护的文件_如何找回已删除或永久删除的Office Excel文件

    恢复删除Excel文件概述 Microsoft Office Excel是微软(Microsoft)为Windows及macOS所设计的试算表软件.它的计算.绘图工具.枢纽分析表和一个称作VBA(Vi ...

  8. c#实现将Excel文件导出为csv和UTF8格式的txt文件

    工作中为了方便,经常使用excel表进行编辑,然后转换为程序用的csv和txt文件. 用c#做了个小工具,生成的exe文件放到需要转换的excel文件目录,可以实在自动读取该目录下的所有xlsx文件, ...

  9. java poi读取excel文件(xlsx)

    读取excel文件的方法有许多种,这篇文章主要描述通过poi读取excel文件. 先maven导入jar包 <dependency><groupId>org.apache.po ...

  10. Python实现谷歌翻译爬虫,翻译PDF,翻译Excel,支持excel文档打开翻译,支持xlsx,xlsm等格式。

    前言: 这两个Python脚本是我在实习期间完成的,具体来自于小组主管的两个小需求.做完之后感觉还是挺有收获的. 实现谷歌翻译,首先需要将我们写的Python脚本还有需要翻译的文件放到谷歌浏览器的安装 ...

最新文章

  1. 三、开发调试应用程序
  2. python处理表格数据教程_用Python的pandas框架操作Excel文件中的数据教程
  3. sparkshelljarlib_spark-submit 应用程序第三方jar文件
  4. 马氏距离详解(数学原理、适用场景、应用示例代码)
  5. 《推荐系统笔记(七)》因子分解机(FM)和它的推广(FFM、DeepFM)
  6. 详细解读八大无线网络安全技术利弊
  7. FM1288的AEC调试经历,持续更新
  8. 60. cache
  9. 使用工具Android Studio实现一个简单的Android版的新闻APP之美
  10. F30.2018年版本北大中文核心期刊目录
  11. 如何找python 包的位置
  12. 计算机基础教材编写委员,大学计算机基础论文关于凸现应用型人才培养的大学计算机基础教材建设论文范文参考资料...
  13. 要用计算机处理频谱,妙用Adobe Audition 系列教程(二):频谱分析仪 | 小众声学...
  14. 截止失真放大电路_仿真实验1 共射放大电路 视频演示
  15. 如何用计算机求一个正数的算术平方根,《用计算器求一个正数的算术平方根》教学设计...
  16. alooa是华为什么型号_alooa是华为什么型号 华为alooa型号是华为畅享7Plus
  17. 【互补松弛定理】12.7.16省队集训
  18. 用jQuery打造个性网站
  19. Android 第三次作业 contentprovider与resolver
  20. RC522 - NFC刷卡模块

热门文章

  1. 2022年最新前端面试题、高频面试题、面试题总结
  2. mysql 部署master slave_MySQL Master Slave 数据同步,集群。
  3. High-Resolution Net(HRNet) 论文笔记
  4. 怎么把PDF调方向保存?这几个方法值得收藏
  5. HTML5情人节礼物2(女友3D相册)
  6. 服务器金属外壳刮花了怎么修复,pc拉杆箱被磨了怎么办?3方法快速修复(附防刮方式)...
  7. Amazon Shield Advanced 更新 – 自动应用程序层 DDoS 防御
  8. 微信隐藏/显示右上角菜单接口
  9. 传输指令——MOV、FMOV、BMOV、SMOV、SWAP
  10. 以拼音输入法(自然语言处理)为例,简单理解隐含马尔可夫模型