`
sylinx_yqg
  • 浏览: 146724 次
  • 性别: Icon_minigender_1
  • 来自: 福建 漳州
社区版块
存档分类
最新评论

EXCEL宏编程纪念

阅读更多

        不久前被叫去编写宏,这EXCEL宏真是麻烦! 可能以后不会再遇到有编写宏的经历了,故而贴出来以做个纪念:

 Sub direct_Price()
'
'query_dir_volume
'宏由 颜清国编写,时间: 2007-4-9
'
''定义变量
Dim cRows As Integer '总行数
Dim cColumns As Integer '总列数
Dim HEADERCOLORINDEX As Integer  '表头的背景色
Dim cTemp As Integer  '临时计数
Dim sTempString As String  '临时字符串变量
Dim i As Integer  '临时计数
Dim j As Integer  '临时计数
Dim rowIndex As Integer  '临时指示处理到哪里
Dim colIndex As Integer  '临时指示处理到哪里
Dim tempRndColor As Integer  '临时生成的颜色
Dim TABLENAME As String  '待处理的表名

Dim colorIndex As String  '颜色索引名字

''''''''''''''''''''''''''''''''''''''''''''''

'表头的背景色
HEADERCOLORINDEX = 15

colorIndex = 36 '颜色从33开始是比较浅的颜色

TABLENAME = "direct_Price"
'关闭所有弹出的警告消息
Application.DisplayAlerts = False

'设置需要处理的单元表
Sheets(TABLENAME).Select

 '取单元表的总列数与总行数
cRows = Sheets(TABLENAME).UsedRange.Rows.Count
cColumns = Sheets(TABLENAME).UsedRange.Columns.Count
   
''''''''''''''''''''''''''''''''''''''''''''''


   
     '选择所有的单元格
 Range(Cells(1, 1), Cells(cRows, cColumns)).Select
 
   '设置该表中所有单元行高为11.25
 Selection.RowHeight = 11.25
 

   
'设置该表中所有单元行高为11.25
 Selection.RowHeight = 11.25
 
 '设置所有的边框
 Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .colorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .colorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .colorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .colorIndex = xlAutomatic
    End With
    With Selection.Borders(xlInsideVertical)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .colorIndex = xlAutomatic
    End With
   
   '并且拆分所有的单元格
 With Selection
        .MergeCells = False '拆分单格
 End With
 
 Columns("C:C").Select
 Selection.Insert Shift:=xlToRight
 
  '删除第一列,注意这里必须先拆分单格,再删除第一列,否则一次就会把合并单元格所在列全部删除
 Range(Cells(1, 1), Cells(1, 1)).Select
 Selection.EntireColumn.Delete
 'Selection.EntireColumn.Delete
 
   '向表头添加一行
  Rows("1:1").Select
  Selection.Insert
 
 
Columns("A:A").Select
Selection.ColumnWidth = 9.29

Columns("B:B").Select
Selection.ColumnWidth = 6.71

Columns("C:C").Select
Selection.ColumnWidth = 15.29

Columns("D:D").Select
Selection.ColumnWidth = 29.86

Columns("E:E").Select
Selection.ColumnWidth = 12.29

Columns("F:F").Select
Selection.ColumnWidth = 12.29


   
    '''''''''''''''''''''''''''''''''''设定单元格A1:A2''''''''''''''''''''
     '合并A1:A2单元格
    Range("A1:A2").Select
   
    '将数据写回
     With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlCenter
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = True
    End With
   
    '往该单元格中写入Usage_Var
    ActiveCell.FormulaR1C1 = "Price"
   
   
    '设置该单元格字体格式
    With ActiveCell.Characters(Start:=1, Length:=5).Font
        .Name = "Arial"
        .FontStyle = "加粗 倾斜"
        .Size = 10
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .colorIndex = 2
    End With
   
    '单元格设定边框
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    Selection.Borders(xlEdgeTop).LineStyle = xlNone
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .colorIndex = 56
    End With
    Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
   
    With Selection.Interior
        .colorIndex = 5
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
    End With
   
  '''''''''''''''''''''''''''''设定头两行的内部样式'''''''''''''''''''''''
    
     Range("B1:B2").Select
     Selection.Merge
   
     Range("C1:C2").Select
    Selection.Merge
    
     Range("D1:D2").Select
     Selection.Merge
    
    
    Range("B1:D2").Select
   
  '设置头两行行高为11.25
   Selection.RowHeight = 14.25
  
    With Selection.Font
        .Name = "Arial"
        .FontStyle = "加粗"
        .Size = 8
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .colorIndex = xlAutomatic
    End With
   
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlCenter
        .WrapText = True
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
    End With
   
    With Selection.Interior
        .colorIndex = HEADERCOLORINDEX
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
    End With
   
   
    Range("B1:B2").Select
    ActiveCell.FormulaR1C1 = "Type"
    With ActiveCell.Characters(Start:=1, Length:=4).Font
        .Name = "Arial"
        .FontStyle = "加粗"
        .Size = 8
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .colorIndex = 5
    End With
   
   
     Range("E1:F1").Select
         With Selection.Font
        .Name = "Arial"
        .FontStyle = "加粗"
        .Size = 8
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .colorIndex = 5
    End With
   With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlCenter
        .WrapText = True
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = True
    End With
   
    With Selection.Interior
        .colorIndex = HEADERCOLORINDEX
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
    End With
     ActiveCell.FormulaR1C1 = "Price"
    
    Range("E2:F2").Select
   
  '设置头两行行高为11.25
   Selection.RowHeight = 14.25
  
    With Selection.Font
        .Name = "Arial"
        .FontStyle = "加粗"
        .Size = 8
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .colorIndex = xlAutomatic
    End With
   
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlCenter
        .WrapText = True
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
   
    With Selection.Interior
        .colorIndex = HEADERCOLORINDEX
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
    End With
   
   
    '加第一二行边框
    Range("A1:F2").Select
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .colorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .colorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .colorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .colorIndex = xlAutomatic
    End With
    With Selection.Borders(xlInsideVertical)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .colorIndex = xlAutomatic
    End With
    With Selection.Borders(xlInsideHorizontal)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .colorIndex = xlAutomatic
    End With
  
  
    '去掉第三行的:号
    'sTempString = Right(Cells(3, 1), Len(Cells(3, 1)) - 3)
    'ActiveCell.FormulaR1C1 = sTempString
   
    i = 2
    j = 1
    
   '外层循环判断是否都合并完成,这里插入了一行,加1
   While i <= cRows
   ' i = i + 1
   
     Range(Cells(i + 1, j), Cells(i + 1, j)).Select
    
    '去掉分类行中的:号
    If (Len(Cells(i + 1, j)) >= 3) Then
      ''''''''''''''如果是分格的界限''''''''''''''''''''''''''''''''''''
      If (Left(Cells(i + 1, j), 3) = " : ") Then
     
          Range(Cells(i + 1, j), Cells(i + 1, cColumns)).Select
         
        '对第三行进行设定
        '设置头两行行高为11.25
        Selection.RowHeight = 18
      With Selection.Interior
         .colorIndex = 2
         .Pattern = xlSolid
         .PatternColorIndex = xlAutomatic
       End With
       '合并前两格
       '先将其合并
      With Selection
        .HorizontalAlignment = xlLeft '靠左对齐
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
       End With
    '合并
     Selection.Merge
    
    '对其设定字体风格
    With Selection.Font
        .Name = "Arial"
        .FontStyle = "加粗 倾斜"
        .Size = 9
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .colorIndex = 3
    End With
   
    With Selection
        .HorizontalAlignment = xlLeft
        .VerticalAlignment = xlCenter
        .WrapText = True
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = True
    End With
   
        sTempString = Right(Cells(i + 1, j), Len(Cells(i + 1, j)) - 3)
        ActiveCell.FormulaR1C1 = sTempString
        i = i + 1
      End If
    End If
 
 
    i = i + 1
   
    '加1后判断是否到了表尾,没有继续合并处理
    'If (i <= cRows + 1) Then
   
     rowIndex = i
     '取出Cells(i, j)的内容
    sTempString = Cells(i, j)
   
    '循环判断下一个单元格是否和上一个单元格相等,不是则表示到此该合并
   While sTempString = Cells(i + 1, j) And i <= cRows
     i = i + 1
   Wend
  
  
   ''''''''''''''''''''''''''''''''''''设置第一列''''''''''''''''''''''''''''''''''''''''
   '跳出循环表示已经到此该将rowIndex 和 i行合并
   Range(Cells(rowIndex, j), Cells(i, j)).Select
   Selection.Merge
 
    '将原来内容填充进来
    ActiveCell.FormulaR1C1 = sTempString
   '设合并后的单元格的边框
    With Selection
    .HorizontalAlignment = xlCenter
    .VerticalAlignment = xlCenter
    .WrapText = True
    .Orientation = 0
    .AddIndent = False
    .IndentLevel = 0
    .ShrinkToFit = False
    .ReadingOrder = xlContext
    .MergeCells = True
    End With
    Selection.Font.FontStyle = "加粗"
        
     ''''''''''''''''''''''''''''''''''''设置第一列结束''''''''''''''''''''''''''''''''''''''''

     '''''''''''''''''''''''''''''''''''''''设置第二列'''''''''''''''''''''''''''''''''''''''''''''
     Range(Cells(rowIndex, j + 1), Cells(i, j + 1)).Select
          '设置字体
    
     With Selection.Font
     .Name = "Arial"
     .FontStyle = "加粗"
     .Size = 8
     .Strikethrough = False
     .Superscript = False
     .Subscript = False
     .OutlineFont = False
     .Shadow = False
     .Underline = xlUnderlineStyleNone
     .colorIndex = 5
     End With
   
    With Selection
    .HorizontalAlignment = xlCenter
    .VerticalAlignment = xlCenter
    .WrapText = True
    .Orientation = 0
    .AddIndent = False
    .IndentLevel = 0
    .ShrinkToFit = False
    .ReadingOrder = xlContext
    .MergeCells = False
    End With
   
     Selection.Borders(xlDiagonalDown).LineStyle = xlNone
     Selection.Borders(xlDiagonalUp).LineStyle = xlNone
     With Selection.Borders(xlEdgeLeft)
         .LineStyle = xlContinuous
         .Weight = xlThin
         .colorIndex = 56
     End With
     With Selection.Borders(xlEdgeTop)
         .LineStyle = xlContinuous
         .Weight = xlThin
         .colorIndex = 56
     End With
     With Selection.Borders(xlEdgeBottom)
         .LineStyle = xlContinuous
         .Weight = xlThin
         .colorIndex = 56
     End With
     With Selection.Borders(xlEdgeRight)
         .LineStyle = xlContinuous
         .Weight = xlThin
         .colorIndex = 56
     End With
     Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
    
    
    
'''''''''''''''''''''''''''''设置第二列结束'''''''''''''''''''''''''''''''''''''''''''''
  
'''''''''''''''''''''''''修改原来单元格的数据格式''''''''''''''''''''''''''''''''
''''''''''''''''''''''''首先向任一无用的单元格写入数据
   Range(Cells(cRows + 2, cColumns), Cells(cRows + 2, cColumns)).Select
   ActiveCell.FormulaR1C1 = "1"
   '将其格式拷贝
   Selection.Copy
  '复制格式
   Range(Cells(rowIndex, j + 4), Cells(i, cColumns)).Select
   Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlMultiply, _
   SkipBlanks:=False, Transpose:=False
   Selection.NumberFormatLocal = "_*#,##0.00000"
   '清除原来内容
   Range(Cells(cRows + 2, cColumns), Cells(cRows + 2, cColumns)).Select
   Selection.ClearContents

''''''''''''''''''''''''设定数据格式完成''''''''''''''''''''''''''''''''''''''''''''''


 '''''''''''''''''''''''''''''''''''''''统一设置该区域的颜色''''''''''''''''''''''''''''''''''''''''''''''
     '设置内部填充
     Range(Cells(rowIndex, j), Cells(i, cColumns)).Select
    
     colorIndex = colorIndex + 1
     If colorIndex > 39 Then
        colorIndex = 33
    End If
   
     With Selection.Interior
             .colorIndex = colorIndex '颜色
             .Pattern = xlSolid
             .PatternColorIndex = xlAutomatic
     End With
 ''''''''''''''''''''''''''''''''''统一设置该区域的颜色结束''''''''''''''''''''''''''''''''''''''''''''''
 

'''''''''''''''''''''''''''''设置剩余的列'''''''''''''''''''''''''''''''''''''''''''''
    Range(Cells(rowIndex, j + 2), Cells(i, cColumns)).Select
   
    '设置字体
   With Selection.Font
      .Name = "Arial"
      .FontStyle = "常规"
      .Size = 8
      .Strikethrough = False
       .Superscript = False
      .Subscript = False
     .OutlineFont = False
       .Shadow = False
     .Underline = xlUnderlineStyleNone
     .colorIndex = xlAutomatic
     End With
    
    '设置第6列
    Range(Cells(rowIndex, j + 4), Cells(i, j + 5)).Select
          '设置字体
     With Selection.Font
      .Name = "Arial"
      .FontStyle = "常规"
      .Size = 8
      .Strikethrough = False
       .Superscript = False
      .Subscript = False
     .OutlineFont = False
       .Shadow = False
     .Underline = xlUnderlineStyleNone
     .colorIndex = 3
     End With
    
    
         
    '''''''''''''''''''''''''''''设置全部的边框'''''''''''''''''''''''''''''''''''''''''''''
    Range(Cells(rowIndex, j), Cells(i, cColumns)).Select
    '设置边框
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .colorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .colorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .colorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .colorIndex = xlAutomatic
    End With
    With Selection.Borders(xlInsideVertical)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .colorIndex = xlAutomatic
    End With
    With Selection.Borders(xlInsideHorizontal)
      '  .LineStyle = xlContinuous
        .Weight = xlThin
       ' .colorIndex = xlAutomatic
    End With
Wend


 Range(Cells(rowIndex - 1, 1), Cells(rowIndex - 1, cColumns)).Select
 Selection.MergeCells = False
 
 
 Range(Cells(rowIndex - 1, cColumns - 1), Cells(rowIndex - 1, cColumns - 1)).Select
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlCenter
        .WrapText = True
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    With Selection.Font
        .Name = "Arial"
        .FontStyle = "加粗"
        .Size = 8
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .colorIndex = xlAutomatic
    End With
    With Selection.Interior
        .colorIndex = 15
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
    End With
    ActiveCell.FormulaR1C1 = "Average"
    With ActiveCell.Characters(Start:=1, Length:=7).Font
        .Name = "Arial"
        .FontStyle = "加粗"
        .Size = 8
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .colorIndex = xlAutomatic
    End With
   
    Range(Cells(rowIndex - 1, cColumns), Cells(rowIndex - 1, cColumns)).Select
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlCenter
        .WrapText = True
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    With Selection.Font
        .Name = "Arial"
        .FontStyle = "加粗"
        .Size = 8
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .colorIndex = xlAutomatic
    End With
    With Selection.Interior
        .colorIndex = 15
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
    End With
    ActiveCell.FormulaR1C1 = "Average"
    With ActiveCell.Characters(Start:=1, Length:=7).Font
        .Name = "Arial"
        .FontStyle = "加粗"
        .Size = 8
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .colorIndex = xlAutomatic
    End With
    
    
    Range(Cells(rowIndex - 1, cColumns - 1), Cells(rowIndex - 1, cColumns)).Select
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .colorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .colorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .colorIndex = xlAutomatic
    End With
    With Selection.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .colorIndex = xlAutomatic
    End With
    With Selection.Borders(xlInsideVertical)
        .LineStyle = xlContinuous
        .Weight = xlThin
        .colorIndex = xlAutomatic
    End With
    With Selection.Borders(xlInsideHorizontal)
       ' .LineStyle = xlContinuous
        .Weight = xlThin
       ' .colorIndex = xlAutomatic
    End With
   
End Sub

 




 

分享到:
评论
1 楼 xueweil 2011-01-29  
Selection.ColumnWidth = 9.29

不建议用selection...这种方式做出来的程序后期很麻烦,效率也低.
表格格式建议批量处理.

相关推荐

    Excel模板爱好者制作的万年历.zip

    5. **VBA宏**:高级用户还可以通过VBA编程实现更多自定义功能,例如添加自动滚动年份、快速跳转到指定日期等,使得模板更加智能化。 6. **模板设计**:在界面设计上,考虑到了用户的使用习惯和审美,通常会采用清晰...

    (源码)基于 Koa2 的 FEBLOG API.zip

    # 基于 Koa2 的 FEBLOG API ## 项目简介 FEBLOG API 是一个基于 Node.js 和 Koa2 框架的 RESTful API 服务器,支持多种关系型数据库(如 PostgreSQL、MySQL、MariaDB、SQLite、MSSQL),并使用 Sequelize 作为 ORM。项目支持跨域请求、JSON 数据传输、JWT 身份认证等功能,适用于构建前后端分离的应用。 ## 主要特性和功能 跨域支持通过配置支持跨域请求。 数据传输格式支持 applicationxwwwformurlencoded、multipartformdata、applicationjson 格式的 POST、PUT、DELETE 请求。 JWT 身份认证通过 JWT 实现用户身份认证。 数据库支持使用 Sequelize ORM 支持 PostgreSQL、MySQL、MariaDB、SQLite、MSSQL 等多种数据库。

    存储器实验资料.zip

    存储器实验资料.zip

    (源码)基于 Python 的知乎热榜爬虫及数据处理项目.zip

    # 基于 Python 的知乎热榜爬虫及数据处理项目 ## 项目简介 本项目基于 Python 编程语言,旨在实现知乎热榜的定时跟踪以及相关数据的存储与查询操作。通过爬虫技术获取知乎热榜问题的详细信息,将数据存入数据库,同时提供一系列 SQL 查询示例帮助用户熟悉 SQL 基本语法,还包含使用 Selenium 实现 GPA 计算器的功能。 ## 项目的主要特性和功能 1. 知乎热榜爬虫定期爬取知乎热榜,获取问题摘要、描述、热度、访问人数、回答数量等基本信息,并将数据存入数据库。 2. 可定制爬虫逻辑用户可以选择删除已有代码从零开始编写,也可以完成代码填空实现相应功能。 3. GPA 计算器使用 Selenium 模拟点击登录 WebVPN,登录 info 并访问成绩单页面,查询成绩并计算每学期的绩点。 4. SQL 练习提供一系列基于 MySQL 数据库的 SQL 查询练习,帮助用户熟悉基本的 SQL 语法,如添加新列、数据填充、关键词查询等。

    (源码)基于C语言的学生信息管理系统.zip

    # 基于C语言的学生信息管理系统 ## 项目简介 这是一个基于文本界面的学生信息管理系统,旨在通过简单的文本输入实现学生信息的添加、查找、修改和删除操作。系统采用链表数据结构存储学生信息,并支持文件读写功能以持久化存储数据。 ## 项目的主要特性和功能 ### 主要特性 1. 文本界面操作用户通过控制台输入指令完成操作。 2. 链表数据结构使用链表存储学生信息,方便信息的添加和删除。 3. 文件操作支持将学生信息数据保存到文件,以及从文件中读取数据。 ### 功能详解 登录验证用户需输入正确的学号和密码才能进入系统。 主界面展示显示系统主菜单,包括学生信息查找、删除、添加、修改和录入等功能。 学生信息查找根据学号查找学生信息。 学生信息删除根据学号删除学生信息。 学生信息添加可以添加新的学生信息到系统中。 学生信息修改可以修改已存在的学生信息。 学生信息录入展示所有存储的学生信息。 辅助功能

    (源码)基于VS Code的px到rpx转换工具.zip

    # 基于VS Code的px到rpx转换工具 ## 项目简介 本项目是一款VS Code插件,旨在将前端代码里的单位px转换为rpx。当设计师在设计稿中使用px单位时,开发者能够借助该工具快速把代码中的px转换为小程序适用的rpx单位。它借助语法分析技术实现精准转换,避免误改其他属性里的px。 ## 项目的主要特性和功能 1. 自动转换功能能通过简单命令自动识别并转换style标签内所有声明中的px为rpx。 2. 精准转换利用语法分析,仅对真正的单位值进行转换,防止错误修改其他内容中的px字符。 3. 部分转换支持可选择部分样式代码进行转换,操作灵活便捷。 ## 安装使用步骤 假设用户已下载本项目源码文件且安装了VS Code环境。 1. 安装插件打开VS Code,进入侧边栏的扩展视图,搜索并安装“px2rpx”插件。 2. 重启VS Code安装完成后重启VS Code使插件生效。

    test文件资包 传递使用

    test文件资包。传递使用

    LCCC2701 智能车灯控制系统设计 20250329

    主控:AT89C52 显示:LCD1602 光照检测:光敏电阻 距离检测:超声波测距 远光灯 近光灯 按键(设置阈值) 1、使用光敏电阻实时检测环境光线强度,设置阈值判断是否开启远光灯; 2、利用超声波传感器测量迎面车辆距离,设置安全距离阈值,自动切换到近光灯; 3、加入延时功能(例如在检测到迎面车辆后等待3秒再切换灯光),以减少频繁切换,提升平滑性。 4、所选传感器模块、执行器模块、电源与接口电路等模块的型号需要是便宜的。

    ESP32之阿里云OTA固件升级(源码)

    esp-idf-v5.3.2

    信息安全领域实战项目【信息安全领域】实战项目汇总:涵盖网络渗透测试、Web应用安全加固、企业安全策略制定等内容多个信息安全领域的实战

    内容概要:本文介绍了多个信息安全领域的实战项目,涵盖网络渗透测试、Web应用安全加固、企业安全策略制定与实施、恶意软件分析、数据泄露应急响应、物联网设备安全检测、区块链安全审计和云安全防护。每个项目都详细描述了其目标和具体实施步骤,包括信息收集、漏洞扫描、利用和修复、安全配置、风险评估、制度建设、培训教育、样本获取与分析、事件响应、遏制措施、调查取证、数据恢复、安全检测、架构分析、智能合约审计、共识机制审查、云环境评估、访问管理、网络安全防护等方面。 适合人群:信息安全从业者、IT管理人员、安全顾问、系统管理员、开发人员以及对信息安全感兴趣的人员。 使用场景及目标:①为信息安全从业人员提供实际操作指导,帮助其掌握不同场景下的安全防护技能;②为企业提供全面的信息安全保障方案,确保其信息系统和数据的安全性;③为开发人员提供安全编码和系统设计的最佳实践指南,提高应用程序的安全性;④为安全研究人员提供深入分析恶意软件和区块链系统的工具和方法。 阅读建议:读者可以根据自身需求选择感兴趣的部分进行深入学习,建议结合实际案例进行实践操作,同时关注最新的安全技术和法规要求,以确保所学知识与时俱进并能应用于实际工作中。

    (源码)基于C语言和STM32F0系列微控制器的宏键盘系统.zip

    # 基于C语言和STM32F0系列微控制器的宏键盘系统 ## 项目简介 本项目是基于C语言和STM32F0系列微控制器开发的宏键盘系统。该系统可让用户自定义宏按键,实现快速输入或自动化任务,涵盖硬件的GPIO输入输出控制、USB通信以及中断处理等功能。 ## 项目的主要特性和功能 宏定义用户能通过定义keymappings.h文件中的宏按键,自定义按键行为。 USB通信利用STM32F0系列微控制器的USB库,支持HID类通信。 GPIO控制实现对键盘按键读取和发送操作的控制。 中断处理可处理按键状态变化、USB通信等外部中断请求。 电源管理对微控制器的睡眠、停止和待机等电源模式进行管理。 ## 安装使用步骤 ### 硬件准备 确保STM32F0系列微控制器(如STM32F042K6)的GPIO引脚、USB接口等硬件连接正确。 保证所有必要外设(如LED、按键)正确连接且可用。 ### 软件准备 下载并解压项目源代码。

    COMSOL多物理场仿真中熔池枝晶模型的构建与应用

    内容概要:本文详细介绍了如何利用COMSOL Multiphysics软件构建熔池枝晶模型,用于模拟金属在凝固过程中枝晶的生长行为。主要内容涵盖三个关键模块:传热、流体流动和相场。通过定义相应的偏微分方程(如传热方程、Navier-Stokes方程和相场方程),设置适当的边界条件和初始条件,并进行多物理场耦合求解,最终实现了对熔池温度分布、速度场及枝晶生长过程的精确模拟。此外,还探讨了如何优化求解器配置、处理移动边界条件、引入各向异性效应以及提高计算效率的方法。 适合人群:从事材料科学、冶金工程、增材制造等领域研究的专业人士和技术人员。 使用场景及目标:适用于需要深入了解金属凝固过程中微观结构演变机制的研究项目,特别是在激光熔覆、焊接等工艺中,帮助研究人员预测和优化材料性能。 其他说明:文中不仅提供了详细的建模步骤指导,还包括一些实用技巧,如参数选择、网格划分策略、热源耦合方式等,有助于解决实际建模过程中可能遇到的问题。

    基于COMSOL的地下二氧化碳封存多物理场耦合仿真研究

    内容概要:本文详细介绍了利用COMSOL Multiphysics进行地下二氧化碳封存仿真的方法和技术要点。主要内容涵盖两相流模块设置、温度场耦合、地层分层建模以及力学模块处理等方面。文中不仅提供了具体的数学模型和代码片段,如相对渗透率函数、热膨胀系数函数等,还分享了许多实际操作中的经验和教训,强调了不同物理场之间的相互作用及其对模拟结果的影响。 适合人群:从事地质工程、环境科学、石油工程等领域研究的专业人士,尤其是那些需要进行地下流体运移和储层特性研究的科研工作者。 使用场景及目标:适用于希望深入了解地下二氧化碳封存机制的研究人员,帮助他们掌握如何使用COMSOL软件构建复杂的多物理场耦合模型,从而更好地预测和评估二氧化碳封存的安全性和有效性。 其他说明:文章中提到的技术细节对于确保模拟精度至关重要,例如正确处理单位转换、选择合适的渗透率模型、考虑温度变化对岩石性质的影响等。此外,作者还提醒读者应注意避免一些常见的错误配置,以免导致不可靠的结果。

    ENCAP 2023打分表

    ENCAP 2023打分表

    中国上市公司协会:2022年中国上市公司董事会秘书履职报告.pdf

    中国上市公司协会:2022年中国上市公司董事会秘书履职报告

    MATLAB遗传算法解决电动车带时间窗路径规划与充电优化问题

    内容概要:本文详细介绍了利用MATLAB遗传算法解决带有时间窗约束的电动车路径规划和充电优化问题。首先,构建了客户点、充电站以及电动车的基本参数模型,然后设计了一套完整的遗传算法框架,包括染色体编码、适应度函数、交叉变异操作等。适应度函数综合考虑了总行驶距离、时间窗违约、电量透支等多个因素。通过多次迭代优化,最终得到了较优的路径规划方案,并展示了实验结果的可视化图形。此外,文中还讨论了一些调参技巧和实际应用中的注意事项。 适合人群:具有一定编程基础和技术背景的研究人员、工程师,特别是从事智能交通系统、物流配送优化领域的专业人士。 使用场景及目标:适用于需要进行电动车路径规划和充电管理的实际应用场景,如城市物流配送公司。主要目标是在满足客户需求和服务质量的前提下,最小化运营成本,提高车辆利用率。 其他说明:文中提供了详细的代码实现步骤和部分实验数据,有助于读者理解和复现研究结果。同时提到了一些实用的小技巧,如适当放宽时间窗惩罚系数可以降低总成本等。

    (源码)基于Arduino的超声波距离测量系统.zip

    # 基于Arduino的超声波距离测量系统 ## 项目简介 本项目是一个基于Arduino平台的超声波距离测量系统。系统包含四个超声波传感器(SPS)模块,用于测量与前方不同方向物体的距离,并通过蜂鸣器(Buzz)模块根据距离范围给出不同的反应。 ## 项目的主要特性和功能 1. 超声波传感器(SPS)模块每个模块包括一个超声波传感器和一个蜂鸣器。传感器用于发送超声波并接收回波,通过计算超声波旅行时间来确定与物体的距离。 2. 蜂鸣器(Buzz)模块根据超声波传感器测量的距离,蜂鸣器会给出不同的反应,如延时发声。 3. 主控制器(Arduino)负责控制和管理所有传感器和蜂鸣器模块,通过串行通信接收和发送数据。 4. 任务管理通过主控制器(Arduino)的 loop() 函数持续执行传感器任务(Task),包括测距、数据处理和蜂鸣器反应。 ## 安装使用步骤 1. 硬件连接

    COMSOL仿真中偶极光源的建模与优化方法详解

    内容概要:本文详细介绍了如何使用COMSOL进行偶极光源的建模与仿真。首先解释了偶极子光源的物理本质及其重要性,然后逐步指导读者完成从创建新模型、设置电流源、配置边界条件到最终结果分析的全过程。文中强调了关键步骤如正确设置电流分量、选择合适的边界条件(如PML)、合理划分网格以及如何解读远场辐射图等。此外,还提供了多个实用技巧和常见错误规避方法,帮助用户提高仿真的准确性和效率。 适合人群:从事光学仿真、电磁场研究的专业人士和技术爱好者。 使用场景及目标:适用于需要精确模拟微纳尺度下电磁波行为的研究项目,特别是涉及偶极子光源的应用场合。通过掌握这些技能,可以更好地理解和预测实际物理现象,从而为相关领域的科研工作提供有力支持。 其他说明:文章不仅涵盖了基本的操作流程,还包括了许多作者亲身经历的经验分享,使读者能够避开一些常见的陷阱并获得更好的仿真效果。同时,文中提供的代码片段可以帮助用户快速上手,将理论知识转化为具体实践。

    COMSOL在多物理场扩散模型中的应用及优化:从电化学到地质工程

    内容概要:本文详细介绍了COMSOL Multiphysics在多种扩散模型中的应用,涵盖电化学、多孔介质中的流体运移、岩石裂隙中的浆液扩散等领域。通过具体的代码片段展示了如何模拟电双层纳米电极中的扩散、二氧化碳混相驱替、岩石裂隙中的浆液扩散以及三层顶板随机裂隙浆液扩散等过程。文中强调了COMSOL的强大多物理场耦合能力和灵活性,特别是在处理复杂系统如煤颗粒的吸附/解吸行为时的优势。此外,还讨论了模型参数调整、边界条件设置、数值稳定性等问题,并分享了一些实践经验和技术细节。 适合人群:从事电化学、地质工程、油气田开发等相关领域的科研人员和工程师。 使用场景及目标:①研究电化学过程中离子迁移和电荷分布的变化;②模拟二氧化碳在多孔介质中的运移规律,优化油气采收率;③分析浆液在岩石裂隙中的扩散规律,指导注浆工程的设计;④探讨煤颗粒的吸附/解吸行为,提升煤层气开采和CO2封存的效果。 其他说明:文中提供了大量具体的技术细节和代码片段,有助于读者理解和复现相关模型。同时,作者分享了许多实际操作中的经验和技巧,对于初学者和有一定经验的研究人员都有很高的参考价值。

    时序预测领域的CPO-ELM-ABKDE模型:融合豪猪优化与自适应核密度估计的高效预测系统

    内容概要:本文介绍了一种新颖的时序预测模型CPO-ELM-ABKDE,它结合了冠豪猪优化(CPO)、极限学习机(ELM)以及自适应带宽核密度估计(ABKDE),用于多变量时序预测和区间概率预测。首先,利用时间滑窗技术将原始数据转换为多变量输入矩阵,然后采用CPO优化ELM的输入权重和偏置,提高预测准确性并防止过拟合。接着,通过ABKDE对预测残差进行建模,生成自适应的概率预测区间。实验结果显示,该模型在电力负荷预测任务中表现出色,点预测R²达到0.97,95%置信区间的覆盖率达到92.3%。 适用人群:从事数据分析、机器学习研究的专业人士,尤其是关注时序预测及其应用的研究者和技术开发者。 使用场景及目标:适用于需要精确时序预测的应用场合,如电力系统负荷预测、金融市场价格走势预测等。主要目标是在确保较高预测精度的同时提供可靠的不确定度量化,帮助决策者更好地应对潜在的风险。 其他说明:文中提供了详细的代码实现步骤,包括数据预处理、模型搭建、训练优化以及结果评估等多个环节。此外,还讨论了不同优化算法之间的性能比较,并强调了本模型对于处理实际工业数据的良好适应性和稳定性。

Global site tag (gtag.js) - Google Analytics