⑴ 別人用excel表格做的管理系統怎麼查看此管理系統的源碼
新建excel文件,alt+F11進入VBA編輯器,插入模塊,輸入以下代碼:
Sub MoveProtect()
Dim FileName As String
FileName = Application.GetOpenFilename("Excel文件(*.xls & *.xla),*.xls;*.xla", , "VBA破解")
If FileName = CStr(False) Then
Exit Sub
Else
VBAPassword FileName, False ' 引用下面的自定義函數
End If
End Sub
Private Function VBAPassword(FileName As String, Optional Protect As Boolean = False)
If Dir(FileName) = "" Then
Exit Function
Else
FileCopy FileName, FileName & ".bak"
End If
Dim GetData As String * 5
Open FileName For Binary As #1
Dim CMGs As Long
Dim DPBo As Long
For i = 1 To LOF(1)
Get #1, i, GetData
If GetData = "CMG=""" Then CMGs = i
If GetData = "[Host" Then DPBo = i - 2: Exit For
Next
If CMGs = 0 Then
MsgBox "請先對VBA編碼設置一個保護密碼...", 32, "提示"
Exit Function
End If
If Protect = False Then
Dim St As String * 2
Dim s20 As String * 1 '取得一個0D0A十六進制字串
Get #1, CMGs - 2, St '取得一個20十六制字串
Get #1, DPBo + 16, s20 '替換加密部份機碼
For i = CMGs To DPBo Step 2
Put #1, i, St
Next '加入不配對符號
If (DPBo - CMGs) Mod 2 <> 0 Then
Put #1, DPBo + 1, s20
End If
MsgBox "文件解密成功......", 32, "提示"
Else
Dim MMs As String * 5
MMs = "DPB="""
Put #1, CMGs, MMs
MsgBox "對文件特殊加密成功......", 32, "提示"
End If
Close #1
End Function
2. 運行上面的代碼,選擇你的文件,移除密碼成功後打開文件,按alt+F11查看源碼:
⑵ 在EXCEL中如何編寫程序
1、打開excel軟體,點擊左上角「文件」;
⑶ 求excel中sum函數源代碼
問題有點復雜化!
其腔唯實,能理解函數語法即可。如:
SUM(number1,number2, ...)
其中,Number1, number2, ... 為 1 到 30 個需要求和的參數慎圓昌。
函數源代碼是計算機編程語言。如:
假設函數:=SUM(A1:A100)
用VBA 編寫的就是(在B1得出求和結果)寬扒:
Sub Macro()
Sheet1.[B1] = Application.Sum(Sheet1.[A1:A100])
End Sub
是不是要這樣?
⑷ 求個 c# 讀取excel 的 源碼,可以運行的。
採用OleDB讀取EXCEL文件:亮尺
把EXCEL文件當做一個數據源來進行數據的讀取操作,實念前例如下:
public DataSet ExcelToDS(string Path)
{
string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" +"Data Source="+ Path +";"+"Extended Properties=Excel 8.0;";
OleDbConnection conn = new OleDbConnection(strConn);
conn.Open();
string strExcel = "";
OleDbDataAdapter myCommand = null;
DataSet ds = null;
strExcel="select * from [sheet1$]";
myCommand = new OleDbDataAdapter(strExcel, strConn);
ds = new DataSet();
myCommand.Fill(ds,"table1");
return ds;
}
對於EXCEL中的表即sheet([sheet1$])如果不是固定的可以使用下面的方法得到
string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" +"Data Source="+ Path +";"仔鍵清+"Extended Properties=Excel 8.0;";
OleDbConnection conn = new OleDbConnection(strConn);
DataTable schemaTable = objConn.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables,null);
string tableName=schemaTable.Rows[0][2].ToString().Trim();
⑸ VB 操作EXCEL 源碼
'工程-引用-Microsoft Excel Object library(勾選此項)
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
'寫文件
Private Sub Command1_Click()
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add '新建EXCEL工件簿文件
Set xlSheet = xlBook.Worksheets(1)
For i = 1 To 10 '10行
For j = 1 To 10 '10列
xlSheet.Cells(i, j) = i * j
Next j
Next i
xlSheet.SaveAs "d:\test.xls" '按指定文件名存檔
xlApp.Quit '結束EXCEL對象
Set xlApp = Nothing '釋放xlApp對象
End Sub
'讀文件
Private Sub Command2_Click()
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Application.Workbooks.Open("d:\test.xls")
Set xlSheet = xlBook.Worksheets(1)
Dim s As String
For i = 1 To 10 '讀取10行
For j = 1 To 10 '讀取10列
s = s & xlSheet.Cells(i, j) & Space(5)
Next j
s = s & vbNewLine '另起一行
Next i
Print s
xlApp.Quit '結束EXCEL對象
Set xlApp = Nothing '釋放xlApp對象
End Sub
兩個命令按鈕,先寫文件,再讀出來輸出到窗體,最簡單的讀寫操作。