當前位置:首頁 » 存儲配置 » 列表表格存儲和讀取

列表表格存儲和讀取

發布時間: 2022-12-30 23:58:10

『壹』 易語言超級列表框內容的保存與讀取

.版本 2
.支持庫 iext

.局部變數 i, 整數型
.局部變數 數據, 文本型

.計次循環首 (超級列表框1.取表項數 (), i)
數據 = 數據 + 超級列表框1.取標題 (i - 1, 1) + #換行符
輸出調試文本 (數據)
.計次循環尾 ()
寫到文件 (取運行目錄 () + 「\數據.txt」, 到位元組集 (數據))

『貳』 利用python批量讀取excel數據並按順序保存至新表

一般需要數據處理時我們會使用excel表格,並可使用其自帶的求和、排序等功能對數據進行處理,但對於某些復雜的處理,我們可以使用python工具來讀取excel數據,並通過python編程,來實現自己所需要的數據處理結果和數據保存方式。

『叄』 vb獲取excel數據並存儲資料庫表中

VB編程軟體可使用適當的數據控制項,通過編程語言和sql結構化查詢語句,能實現獲取excel數據並存儲到其它資料庫表中。

『肆』 python讀取excel文件,將每一行都保存為一個列表。每一行對應一個列表。

python讀寫excel文件要用到兩個庫:xlrd和xlwt,首先下載安裝這兩個庫。

1、#讀取Excel

importxlrd

data = xlrd.open_workbook(excelFile)

table = data.sheets()[0]

nrows = table.nrows #行數

ncols = table.ncols #列數

for i in xrange(0,nrows):
rowValues= table.row_values(i) #某一行數據
for item in rowValues:
printitem

2、寫Excel文件

'''往EXCEl單元格寫內容,每次寫一行sheet:頁簽名稱;row:行內容列表;rowIndex:行索引;

isBold:true:粗欄位,false:普通字體'''

defWriteSheetRow(sheet,rowValueList,rowIndex,isBold):

i = 0

style = xlwt.easyxf('font: bold 1')

#style = xlwt.easyxf('font: bold 0, color red;')#紅色字體

#style2 = xlwt.easyxf('pattern: pattern solid, fore_colour yellow; font: bold on;') # 設置Excel單元格的背景色為黃色,字體為粗體

forsvalue inrowValueList:

strValue = unicode(str(svalue),'utf-8')

ifisBold:

sheet.write(rowIndex,i,strValue,style)

else:

sheet.write(rowIndex,i,strValue)

i = i + 1

'''寫excel文件'''

defsave_Excel(strFile):

excelFile = unicode(strFile,"utf8")

wbk = xlwt.Workbook()

sheet = wbk.add_sheet('sheet1',cell_overwrite_ok=True)

headList = ['標題1','標題2','標題3','標題4','總計']

rowIndex = 0

WriteSheetRow(sheet,headList,rowIndex,True)

fori inxrange(1,11):

rowIndex = rowIndex + 1

valueList = []

forj inxrange(1,5):

valueList.append(j*i)

WriteSheetRow(sheet,valueList,rowIndex,False)

wbk.save(excelFile)

style2 = xlwt.easyxf('pattern: pattern solid, fore_colour yellow; font: bold on;')

在設置上Excel單元格的背景色時,fore_colour支持的顏色是有限的,僅支持一下顏色

aqua 0x31
black 0x08
blue 0x0C
blue_gray 0x36
bright_green 0x0B
brown 0x3C
coral 0x1D
cyan_ega 0x0F
dark_blue 0x12
dark_blue_ega 0x12
dark_green 0x3A
dark_green_ega 0x11
dark_purple 0x1C
dark_red 0x10
dark_red_ega 0x10
dark_teal 0x38
dark_yellow 0x13
gold 0x33
gray_ega 0x17
gray25 0x16
gray40 0x37
gray50 0x17
gray80 0x3F
green 0x11
ice_blue 0x1F
indigo 0x3E
ivory 0x1A
lavender 0x2E
light_blue 0x30
light_green 0x2A
light_orange 0x34
light_turquoise 0x29
light_yellow 0x2B
lime 0x32
magenta_ega 0x0E
ocean_blue 0x1E
olive_ega 0x13
olive_green 0x3B
orange 0x35
pale_blue 0x2C
periwinkle 0x18
pink 0x0E
plum 0x3D
purple_ega 0x14
red 0x0A
rose 0x2D
sea_green 0x39
silver_ega 0x16
sky_blue 0x28
tan 0x2F
teal 0x15
teal_ega 0x15
turquoise 0x0F
violet 0x14
white 0x09
yellow 0x0D"""

另外一種方式是 用pyExcelerator

from pyExcelerator import *# excel 第一行數據excel_headDatas = [u'發布時間', u'文章標題', u'文章鏈接', u'文章簡介']
articles =[
{u'發布時間':u'2017年5月9日',
u'文章標題':u'Python項目實戰教程:國內就能訪問的google搜索引擎',
u'
u'文章簡介':u'大家可以留言、想了解python那個方向的知識、不然我也不知道'},

{u'發布時間':u'2017年5月4日',
u'文章標題':u'對於學習Django的建議、你知道的有那些',
u'文章鏈接':',
u'文章簡介':u'隨著Django1.4第二個候選版的發布,雖然還不支持Python3,但Django團隊已經在著手計劃中,據官方博客所說,Django1.5將會試驗性的支持python3'}
]# 定義excel操作句柄excle_Workbook = Workbook()
excel_sheet_name = time.strftime('%Y-%m-%d')
excel_sheet = excle_Workbook.add_sheet(excel_sheet_name)
index = 0#標題for data in excel_headDatas:
excel_sheet.write(0, index, data)
index += 1index = 1#內容for article in articles:
colIndex = 0 for item in excel_headDatas:
excel_sheet.write(index, colIndex, article[item])
colIndex += 1
index += 1#保存test.xlsx到當前程序目錄excle_Workbook.save('test.xlsx')# db = mongoDB.mongoDbBase()# db.Get_information_stat()

『伍』 如何用python讀取存儲在postgresql資料庫中的表格

您可以使用mysql哦
會比您這個資料庫好用很多哦
您可以上網搜一搜 mysql有很多解答

熱點內容
java返回this 發布:2025-10-20 08:28:16 瀏覽:597
製作腳本網站 發布:2025-10-20 08:17:34 瀏覽:890
python中的init方法 發布:2025-10-20 08:17:33 瀏覽:584
圖案密碼什麼意思 發布:2025-10-20 08:16:56 瀏覽:768
怎麼清理微信視頻緩存 發布:2025-10-20 08:12:37 瀏覽:688
c語言編譯器怎麼看執行過程 發布:2025-10-20 08:00:32 瀏覽:1015
郵箱如何填寫發信伺服器 發布:2025-10-20 07:45:27 瀏覽:259
shell腳本入門案例 發布:2025-10-20 07:44:45 瀏覽:118
怎麼上傳照片瀏覽上傳 發布:2025-10-20 07:44:03 瀏覽:808
python股票數據獲取 發布:2025-10-20 07:39:44 瀏覽:716