惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Exploit Database - CXSecurity.com
A
Arctic Wolf
K
Kaspersky official blog
T
Threat Research - Cisco Blogs
PCI Perspectives
PCI Perspectives
www.infosecurity-magazine.com
www.infosecurity-magazine.com
P
Privacy International News Feed
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
U
Unit 42
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Simon Willison's Weblog
Simon Willison's Weblog
P
Privacy & Cybersecurity Law Blog
O
OpenAI News
量子位
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
C
Cisco Blogs
AWS News Blog
AWS News Blog
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
美团技术团队
T
Threatpost
S
Schneier on Security
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
C
Cyber Attacks, Cyber Crime and Cyber Security
Last Week in AI
Last Week in AI
C
CERT Recently Published Vulnerability Notes
Blog — PlanetScale
Blog — PlanetScale
C
Cybersecurity and Infrastructure Security Agency CISA
F
Full Disclosure
博客园_首页
N
Netflix TechBlog - Medium
Security Latest
Security Latest
有赞技术团队
有赞技术团队
Google DeepMind News
Google DeepMind News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
The Register - Security
The Register - Security
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Recent Announcements
Recent Announcements
博客园 - Franky
P
Palo Alto Networks Blog
Project Zero
Project Zero
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
H
Help Net Security
Hacker News: Ask HN
Hacker News: Ask HN
Cisco Talos Blog
Cisco Talos Blog
H
Heimdal Security Blog
The Hacker News
The Hacker News
博客园 - 【当耐特】
GbyAI
GbyAI

博客园 - 流云之心

招人啦 - 前端,后台开发专家 为什么不给程序员配好电脑 [翻译] SQL Server中对XML操作 开发常用小工具介绍 设计模式一 - Simple Factory, Factory Method, Abstract Factory以及Builder模式简述 强制休息程序 - EyeGuardian 眼睛守护者 Beta测试版 定时计划任务方案比较以及通过脚本创建计划任务(SchTasks命令) javascript 将页面上的Table导出保存为Excel (无格式) - 流云之心 Excel Programming (C# + VBA) Part III Excel Programming (C# + VBA) Part II Harry Potter - The Half-Blood Prince 转移阵地了,新地址:http://spaces.msn.com/members/PuGong 关于XMLHTTP object的OPEN方法 smart client优势在那里? (草稿) SQL Server的collation问题 Microsoft Interview Question links 转自http://blogs.msdn.com/chappell/archive/2004/07/20/189364.aspx MSN to expand free e-mail storage to 250MB 用 #inculde file = "../fiel" 报1031错误 用<!--include file = ../ --> 报错误1031
Excel programming (C# + VBA) Part 1
流云之心 · 2007-12-03 · via 博客园 - 流云之心

Excel programming (C# + VBA)

Here is the secario of a full process of solution to use excel to submit information.

  •    Clarify the requirement and create the Excel template (VBA)

  • Generate an Excel template to fill with source data (C#)

  • Download the template from web site (C# + ASP.NET)

  • Fill in the template and verified the data via VBA (VBA)

  • Upload the template (Web) (ASP.NET)

  • Import data in Excel Template to database (C#)

1.      Setp 1 Create the Excel Template based on requirement

a.       Clarify the requirement

b.      Create hidden template sheet

                                                               i.      Clarify the data type in each cell, fill in type (user input/list validation or a pop form) and the lock property.

c.       Create hidden data source sheet

                                                               i.      Clarify the source data in each column

                                                             ii.      Create named range for list validation (If the data is already known)

d.      Create Summary, Filling Sheet

                                                               i.      Set the layout, add validation button and Add new button

e.      VBA programming to add list validation or auto-filling 

    

rng.Validation.Add xlValidateList, xlValidAlertStop, xlBetween, "=SpecialOfferType"
    rng.Validation.IgnoreBlank 
= True
    rng.Validation.InCellDropdown 
= True
    

f.        VBA programming to select data in pop form

            With frmChoose
                .CCodeColumn 
= "AB"
                .CNameColumn 
= "B"
                .CRow 
= Target.Row
                .CCodeSourceColumn 
= "B"
                .CNameSourceColumn 
= "C"
                .CKeyWords 
= Me.Cells(iRow, iColumn).Text
                .Caption 
= Me.Cells(iRow, iColumn - 1)
                
Set .CWorksheet = Application.ActiveSheet
                
Set .CSourceWorksheet = sourceSheet
                .Show
            
End With

In frmChoose, when the Ok button is clicked:

        CWorksheet.Unprotect Password
        
        n 
= 2
        
If (CSourceWorksheet Is NothingThen
            name 
= wsDataSource.Range(CNameSourceColumn & n).Text
        
Else
            name 
= CSourceWorksheet.Range(CNameSourceColumn & n).Text
        
End If
        
        
While (name <> "")
            
If name = lstSelected.List(lstSelected.ListIndex) Then
                
If (CSourceWorksheet Is NothingThen
                    code 
= wsDataSource.Range(CCodeSourceColumn & n).Text
                
Else
                    code 
= CSourceWorksheet.Range(CCodeSourceColumn & n).Text
                
End If
            
End If
            
            n 
= n + 1
            
If (CSourceWorksheet Is NothingThen
                name 
= wsDataSource.Range(CNameSourceColumn & n).Text
            
Else
                name 
= CSourceWorksheet.Range(CNameSourceColumn & n).Text
            
End If
        
Wend
        
        
If (CNameColumn <> ""Then
            CWorksheet.Range(CNameColumn 
& CRow).Value2 = lstSelected.List(lstSelected.ListIndex)
        
End If
        
        
If (CCodeColumn <> ""Then
            CWorksheet.Range(CCodeColumn 
& CRow).Value2 = code
        
End If
        
        CWorksheet.Protect Password
        

g.       VBA programming to validate the data filled in every sheets

          If Not CheckDateType(ws.Cells(i, 2).Value) Then
                bCheck 
= False
                
MsgBox ws.Cells(i, 1).Value & "ÄÚÊäÈëµÄ²»ÊÇÓÐЧʱ¼ä"
                ws.Activate
                ws.Cells(i, 
2).Select
                
Exit Sub
          
End If
.....


Function CheckNumberic(sourceString As StringAs Boolean
    
Dim bOk As Boolean
    bOk 
= True
    
If sourceString <> "" And Not IsNumeric(sourceString) Then
        bOk 
= False
    
End If
    
    CheckNumberic 
= bOk
End Function


Function CheckDateType(sourceString As StringAs Boolean
    
Dim bOk As Boolean
    bOk 
= False
    
If sourceString <> "" And IsDate(sourceString) Then
        bOk 
= True
    
End If
    
    CheckDateType 
= bOk
    
End Function

2.