实例2.1 通过控制台实现对Excel的自动化处理 书本第32页

注:添加两个引用:

第一个:程序集—框架—“System.Windows.Forms 4.0.0.0
第二个:程序集—扩展—“Microsoft.Office.Interop.Excel 14.0.0.0”

程序清单2.1通过控制台程序对Excel自动化处理

  1. Imports Excel = Microsoft.Office.Interop.Excel
  2.  
  3. Module Module1
  4.  
  5. Private exitXL As Boolean = False
  6. Dim WithEvents myExcelApp As Excel.Application
  7.  
  8. Sub Main()
  9.  
  10. myExcelApp = New Excel.Application
  11. myExcelApp.Visible = True
  12. myExcelApp.StatusBar = "Hello World"
  13. myExcelApp.Workbooks.Add()
  14.  
  15. While exitXL = False
  16. System.Windows.Forms.Application.DoEvents()
  17. End While
  18.  
  19. End Sub
  20.  
  21. Private Sub myExcelApp_SheetBeforeDoubleClick(ByVal sheet _
  22. As Object, ByVal target As Excel.Range, ByRef cancel _
  23. As Boolean) Handles myExcelApp.SheetBeforeDoubleClick
  24.  
  25. exitXL = True
  26.  
  27. End Sub
  28.  
  29. End Module

实例代码:

  1. Imports Excel = Microsoft.Office.Interop.Excel
  2. Module Module1
  3.  
  4. Private exitXL As Boolean = False
  5. Dim WithEvents myExcelApp As Excel.Application '有这句需添加引用“Microsoft.Office.Interop.Excel 14.0.0.0”
  6. Sub Main()
  7. myExcelApp = New Excel.Application '运行顺序——1
  8. myExcelApp.Visible = True '运行顺序——2
  9. myExcelApp.StatusBar = "Hello World" '运行顺序——3
  10. myExcelApp.Workbooks.Add() '运行顺序——4
  11. While exitXL = False '运行顺序——5 实质就是程序运行到这里,控制台程序不运行了,控制权交给了Excel程序
  12. System.Windows.Forms.Application.DoEvents() '有这句需添加引用“System.Windows.Forms 4.0.0.0”
  13. End While
  14. MsgBox("通过双击单元格,控制权又由Excel转移到控制台!") '运行顺序——7
  15. End Sub
  16.  
  17. Private Sub myExcelApp_SheetBeforeDoubleClick(ByVal sheet As Object, ByVal target As Excel.Range, ByRef cancel As Boolean) Handles myExcelApp.SheetBeforeDoubleClick
  18. exitXL = True '运行顺序——6 实质就是给exitXL重新赋值并传递给While条件语句,接着运行While以后的语句
  19. End Sub
  20.  
  21. End Module
  22. '**************************************************************************
  23. '*双击单元格Office控制权会转回到自动化程序事件处理中, *
  24. '*若没有System.Windows.Forms.Application.DoEvents(),控制台窗口将自动关闭, *
  25. '*System.Windows.Forms.Application.DoEvents()方法可以使窗体处理其他事件, *
  26. '*所以窗体能够进行重绘。不至于出现假死现象。 *
  27. '**************************************************************************

实例效果:

 实例2.2 wiki文本表示形式 书本第33页

程序清单2.2 表2.1的wiki文本表示形式

  1. ||Property or Method||Name||Return Type||
  2. ||Property||Application||Application||
  3. ||Property||Autoload||Boolean||
  4. ||Property||Compiled||Boolean||
  5. ||Property||Creator||Int32||
  6. ||Method||Delete||Void||
  7. ||Property||Index||Int32||
  8. ||Property||Installed||Boolean||
  9. ||Property||Name||String||
  10. ||Property||Parent||Object||
  11. ||Property||Path||String||

实例2.3 将文本文件中的wiki形式的文本以表格的形式输出到Word中 书本37页

程序清单2.3 完整的WordWiki实现

  1. Imports System.Collections.Generic
  2. Imports System.Text
  3. Imports System.IO
  4. Imports Office = Microsoft.Office.Core
  5. Imports Word = Microsoft.Office.Interop.Word
  6.  
  7. Module Module1
  8. Sub Main(ByVal args As String())
  9.  
  10. Dim theApplication As New Word.Application
  11. theApplication.Visible = True
  12. Dim theDocument As Word.Document
  13. theDocument = theApplication.Documents.Add()
  14.  
  15. Dim reader As TextReader
  16. reader = New System.IO.StreamReader(args())
  17.  
  18. Dim separators() As String
  19. separators() = "||"
  20. Dim rowCount As Integer =
  21. Dim columnCount As Integer =
  22.  
  23. ' Read rows and calculate number of rows and columns
  24. Dim rowList As New System.Collections.Generic.List(Of String)
  25. Dim row As String = reader.ReadLine()
  26. While row IsNot Nothing
  27. rowCount +=
  28. rowList.Add(row)
  29.  
  30. ' If this is the first row,
  31. ' calculate the number of columns
  32. If rowCount = Then
  33. Dim splitHeaderRow As String() = _
  34. row.Split(separators, StringSplitOptions.None)
  35.  
  36. ' Ignore the first and last separator
  37. columnCount = splitHeaderRow.Length -
  38. End If
  39.  
  40. row = reader.ReadLine()
  41. End While
  42.  
  43. ' Create a table
  44. Dim range As Word.Range = theDocument.Range()
  45. Dim table As Word.Table = range.Tables.Add(range, _
  46. rowCount, columnCount)
  47.  
  48. ' Populate table
  49. Dim columnIndex As Integer =
  50. Dim rowIndex As Integer =
  51.  
  52. For Each r As String In rowList
  53. Dim splitRow As String() = r.Split(separators, _
  54. StringSplitOptions.None)
  55.  
  56. For columnIndex = To columnCount
  57. Dim cell As Word.Cell = table.Cell(rowIndex, columnIndex)
  58. cell.Range.Text = splitRow(columnIndex)
  59. Next
  60. rowIndex +=
  61. Next
  62.  
  63. ' Format table
  64. table.Rows().Range.Bold =
  65. table.AutoFitBehavior( _
  66. Word.WdAutoFitBehavior.wdAutoFitContent)
  67.  
  68. ' Wait for input from the command line before exiting
  69. System.Console.WriteLine("Table complete.")
  70. System.Console.ReadLine()
  71.  
  72. ' Quit without saving changes
  73. theApplication.Quit(False)
  74. End Sub
  75. End Module

实例代码:

  1. Imports System.Collections.Generic '默认
  2. Imports System.Text '默认
  3. Imports System.IO '默认
  4. Imports Office = Microsoft.Office.Core '添加引用“Microsoft Office 14.0 Object Library 2.5
  5. Imports Word = Microsoft.Office.Interop.Word '添加引用"Microsoft.Office.Interop.word 14.0.0.0"
  6.  
  7. Module Module1
  8. Sub Main(ByVal args As String())
  9.  
  10. Dim theApplication As New Word.Application '定义word程序
  11. theApplication.Visible = True '使word程序可视
  12. Dim theDocument As Word.Document '定义word文档
  13. theDocument = theApplication.Documents.Add() '为程序添加word文档
  14.  
  15. Dim reader As TextReader '定义Txt文本读取器
  16. reader = New System.IO.StreamReader(My.Application.Info.DirectoryPath & "/test.txt") '实例化读取文本接口,My.Application.Info.DirectoryPath指的是本程序的\bin\Debug目录
  17.  
  18. Dim separators() As String '定义分隔符字符串
  19. separators() = "||" '为分隔符变量赋值
  20. Dim rowCount As Integer = '定义行数
  21. Dim columnCount As Integer = '定义列数
  22.  
  23. ' 读取行并计算行数和列数
  24. Dim rowList As New System.Collections.Generic.List(Of String) '定义字符串型的列表集对象
  25. Dim row As String = reader.ReadLine() '读取文本存储器中的一行
  26. While row IsNot Nothing '读取行没有到结尾
  27. rowCount += '读取下一行
  28. rowList.Add(row) '将所读取的一行文本存储在列表集对象中
  29.  
  30. ' 如果这是第一行,就计算列数
  31. If rowCount = Then
  32. Dim splitHeaderRow As String() = row.Split(separators, StringSplitOptions.None) 'StringSplitOptions.None,就是分开的数组元素包括空元素
  33. columnCount = splitHeaderRow.Length - ' 忽略第一和最后一个分隔符,由于第一个和最后一个没有起到分隔作用,所以5个元素减去2个分隔符元素就是所需的列数3
  34. End If
  35. row = reader.ReadLine()'自带逐行读取的功能
  36. End While
  37.  
  38. ' word中创建一个表
  39. Dim range As Word.Range = theDocument.Range() '定义文档单元格
  40. Dim table As Word.Table = range.Tables.Add(range, rowCount, columnCount) '创建一个rowCountcolumnCount列的表格
  41.  
  42. ' 操作word中所创建的表
  43. Dim columnIndex As Integer =
  44. Dim rowIndex As Integer =
  45.  
  46. For Each r As String In rowList
  47. Dim splitRow As String() = r.Split(separators, StringSplitOptions.None) 'StringSplitOptions.None,就是分开的数组元素包括空元素
  48. For columnIndex = To columnCount
  49. Dim cell As Word.Cell = table.Cell(rowIndex, columnIndex) '\bin\Debug目录中test.txt文件中的结尾不能有多余的空行,不然会提示超出索引范围而出现错误
  50. cell.Range.Text = splitRow(columnIndex)
  51. Next
  52. rowIndex +=
  53. Next
  54.  
  55. ' 格式化表格
  56. table.Rows().Range.Bold =
  57. table.AutoFitBehavior(Word.WdAutoFitBehavior.wdAutoFitContent) 'AutoFitBehavior()方法的作用就是以某种方法调整表格,ord.WdAutoFitBehavior.wdAutoFitContent表示表格根据内容来调节
  58.  
  59. ' 退出前等待命令输入
  60. System.Console.WriteLine("Table complete.")
  61. System.Console.ReadLine()
  62.  
  63. ' 没有保存更改而退出
  64. theApplication.Quit(False)
  65. End Sub
  66. End Module

test.txt文档中的内容

  1. ||Property or Method||Name||Return Type||
  2. ||Property||Application||Application||
  3. ||Property||Autoload||Boolean||
  4. ||Property||Compiled||Boolean||
  5. ||Property||Creator||Int32||
  6. ||Method||Delete||Void||
  7. ||Property||Index||Int32||
  8. ||Property||Installed||Boolean||
  9. ||Property||Name||String||
  10. ||Property||Parent||Object||
  11. ||Property||Path||String||

实例效果:

 续:对实例2.3逐步详细解读

        首先,总的功能就是在读取文本文档中的内容并在新创建word中显示出来

  1. Imports Word = Microsoft.Office.Interop.Word '添加引用"Microsoft.Office.Interop.word 14.0.0.0"
  2.  
  3. Module Module1
  4. Sub Main(ByVal args As String())
  5. Dim App As Word.Application = New Word.Application '创建Word实例程序 *
  6. Dim myWord As Word.Document = App.Documents.Add() '创建word文档 *
  7. Dim range As Word.Range = myWord.Range() '创建一个存放内容的区域 *
  8. App.Visible = True '显示Word程序 *
  9.  
  10. Dim reader As New System.IO.StreamReader("D:/test.txt") '读取文本文档,注:文本文档不能为编码文档,不然读过来是乱码!!
  11. Dim str As String = reader.ReadLine() '读取文本文档中的一行,若要读取全部reader.ReadToEnd(),从当前位置读到结尾,
  12. '若真正将每行读取,最好使用System.Collections.Generic集合的概念将每行读取到集合中,用for each遍历即可
  13.  
  14. range.Text = str '将文本文档中的内容赋值给Word中
  15. End Sub
  16. End Module

续2:将文本文档中的内容读取,存入集合中

  1. Imports Word = Microsoft.Office.Interop.Word '添加引用"Microsoft.Office.Interop.word 14.0.0.0"
  2.  
  3. Module Module1
  4. Sub Main(ByVal args As String())
  5. Dim App As Word.Application = New Word.Application '创建Word实例程序 *
  6. Dim myWord As Word.Document = App.Documents.Add() '创建word文档 *
  7. App.Visible = True '显示Word程序 *
  8. Dim reader As New System.IO.StreamReader("D:/test.txt") '读取文本文档,注:文本文档不能为编码文档,不然读过来是乱码!!
  9.  
  10. Dim rowList As New System.Collections.Generic.List(Of String) '定义字符串型的列表集对象
  11. Dim row As String = reader.ReadLine() '读取文本存储器中的一行
  12. While row IsNot Nothing '读取行没有到结尾
  13. rowList.Add(row) '将所读取的一行文本存储在列表集对象中
  14. row = reader.ReadLine() '自带逐行读取的功能
  15. End While
  16.  
  17. Dim range As Word.Range = myWord.Range() '定义文档单元格
  18. Dim table As Word.Table = range.Tables.Add(range, , ) '创建一个111列的表格,硬编码更易理解
  19. Dim rowIndex As Integer =
  20. For Each r As String In rowList
  21. Dim cell As Word.Cell = table.Cell(rowIndex, ) '目录中test.txt文件中的结尾不能有多余的空行,不然会提示超出索引范围而出现错误
  22. cell.Range.Text = r
  23. rowIndex +=
  24. Next
  25.  
  26. End Sub
  27. End Module

 续3:将内容倒着读取出来

  1. Imports Word = Microsoft.Office.Interop.Word '添加引用"Microsoft.Office.Interop.word 14.0.0.0"
  2.  
  3. Module Module1
  4. Sub Main(ByVal args As String())
  5. Dim App As Word.Application = New Word.Application '创建Word实例程序 *
  6. Dim myWord As Word.Document = App.Documents.Add() '创建word文档 *
  7. App.Visible = True '显示Word程序 *
  8. Dim reader As New System.IO.StreamReader("D:/test.txt") '读取文本文档,注:文本文档不能为编码文档,不然读过来是乱码!!
  9.  
  10. Dim rowList As New System.Collections.Generic.List(Of String) '定义字符串型的列表集对象
  11. Dim row As String = reader.ReadLine() '读取文本存储器中的一行
  12. While row IsNot Nothing '读取行没有到结尾
  13. rowList.Add(row) '将所读取的一行文本存储在列表集对象中
  14. row = reader.ReadLine() '自带逐行读取的功能
  15. End While
  16.  
  17. Dim range As Word.Range = myWord.Range() '定义文档单元格
  18. Dim rowIndex As Integer =
  19. For Each r As String In rowList
  20. range = myWord.Range(, ) 'range方法的第一个参数是开头,第二个参数是结尾,这里指第几段,插入值,插入的值是倒着排列的
  21. range.Text = r & Chr() ' 注:chr(10) & chr(13)中,chr(10) 换行符,而 chr(13)回车,那么chr(10) & chr(13)就是既换行了又回车了
  22. rowIndex = rowIndex +
  23. Next
  24. End Sub

续4:myWord.Paragraphs.Add().Range()

  1. Imports Word = Microsoft.Office.Interop.Word '添加引用"Microsoft.Office.Interop.word 14.0.0.0"
  2.  
  3. Module Module1
  4. Sub Main(ByVal args As String())
  5. Dim App As Word.Application = New Word.Application '创建Word实例程序 *
  6. Dim myWord As Word.Document = App.Documents.Add() '创建word文档 *
  7. App.Visible = True '显示Word程序 *
  8. Dim reader As New System.IO.StreamReader("D:/test.txt") '读取文本文档,注:文本文档不能为编码文档,不然读过来是乱码!!
  9.  
  10. Dim rowList As New System.Collections.Generic.List(Of String) '定义字符串型的列表集对象
  11. Dim row As String = reader.ReadLine() '读取文本存储器中的一行
  12. While row IsNot Nothing '读取行没有到结尾
  13. rowList.Add(row) '将所读取的一行文本存储在列表集对象中
  14. row = reader.ReadLine() '自带逐行读取的功能
  15. End While
  16.  
  17. Dim range As Word.Range = myWord.Paragraphs.Add().Range() '定义文档单元格
  18. Dim rowIndex As Integer =
  19. For Each r As String In rowList
  20. range = myWord.Paragraphs(rowIndex).Range()
  21. range.Text = r & Chr() ' 注:chr(10) & chr(13)中,chr(10) 换行符,而 chr(13)回车,那么chr(10) & chr(13)就是既换行了又回车了
  22. rowIndex = rowIndex +
  23. Next
  24. End Sub

实例2.4 Outlook外接程序 书本第40页

  程序清单2.4 Outlook外接程序项目中ThisApplication类的初始化代码

  1. Public Class ThisApplication
  2.  
  3. Private Sub ThisApplication_Startup(ByVal sender As Object, _
  4. ByVal e As System.EventArgs) Handles Me.Startup
  5.  
  6. End Sub
  7.  
  8. Private Sub ThisApplication_Shutdown(ByVal sender As Object, _
  9. ByVal e As System.EventArgs) Handles Me.Shutdown
  10.  
  11. End Sub
  12.  
  13. End Class

   实例代码:

  1. Public Class ThisAddIn
  2.  
  3. Private Sub ThisAddIn_Startup() Handles Me.Startup
  4.  
  5. End Sub
  6.  
  7. Private Sub ThisAddIn_Shutdown() Handles Me.Shutdown
  8.  
  9. End Sub
  10.  
  11. End Class

实例2.5 VSTO Outlook 外接程序 书本41页

注:添加引用”System.Windows.Forms”

程序清单2.5 VSTO Outlook 外接程序,用于处理Item事件和检查收件人数是否超过25

  1. Imports Outlook = Microsoft.Office.Interop.Outlook
  2.  
  3. Public Class ThisApplication
  4. Private Sub ThisApplication_ItemSend(ByVal item As Object, _
  5. ByRef cancel As Boolean) Handles Me.ItemSend
  6.  
  7. Dim myItem As Outlook.MailItem
  8.  
  9. If TypeOf item Is Outlook.MailItem Then
  10. myItem = CType(item, Outlook.MailItem)
  11. For Each recip As Outlook.Recipient In myItem.Recipients
  12. If recip.AddressEntry.Members.Count > Then
  13. ' Ask the user if she really wants to send this e-mail
  14. Dim message As String
  15. message = "Send mail to {0} with {1} people?"
  16. Dim caption As String = "More than 25 recipients"
  17. Dim buttons As MessageBoxButtons
  18. buttons = MessageBoxButtons.YesNo
  19. Dim result As DialogResult
  20.  
  21. result = MessageBox.Show(String.Format(message, _
  22. recip.AddressEntry.Name, _
  23. recip.AddressEntry.Members.Count), _
  24. caption, buttons)
  25.  
  26. If result = DialogResult.No Then
  27. cancel = True
  28. Exit For
  29. End If
  30. End If
  31. Next
  32. End If
  33.  
  34. End Sub
  35. End Class

实例2.6 VSTO Excel工作簿自定义机制  书本42页

程序清单 2.6 VSTO Excel工作簿自定义机制

  1. Imports Excel = Microsoft.Office.Interop.Excel
  2. Imports Office = Microsoft.Office.Core
  3.  
  4. Public Class Sheet1
  5. Private Sub Sheet1_Startup(ByVal sender As Object, _
  6. ByVal e As System.EventArgs) Handles Me.Startup
  7.  
  8. ' Initial entry point.
  9. ' This code gets run first when the code behind is created
  10. ' The context is implicit in the Sheet1 class
  11. MsgBox("Code behind the document running.")
  12. MsgBox(String.Format("{0} is the sheet name.", Me.Name))
  13.  
  14. End Sub
  15.  
  16. End Class

实例代码:

  1. Imports Excel = Microsoft.Office.Interop.Excel
  2. Imports Office = Microsoft.Office.Core
  3. Public Class Sheet1
  4. Private Sub Sheet1_Startup(ByVal sender As Object, _
  5. ByVal e As System.EventArgs) Handles Me.Startup
  6. ' 初始化入口点
  7. ' 创建文档代码时将首次执行此代码
  8. ' 这里的上下环境是sheet1
  9. MsgBox("Code behind the document running.")
  10. MsgBox(String.Format("{0} is the sheet name.", Me.Name))
  11.  
  12. End Sub
  13. End Class

实例效果:

   

实例2.7 VSTO自定义机制:在文档操作任务面板中添加按钮控件以及将ListObject控件与DataTable进行数据绑定   书本46页

程序清单 2.7 VSTO自定义机制:在文档操作任务面板中添加按钮控件以及将ListObject控件与DataTable进行数据绑定

  1. Imports Excel = Microsoft.Office.Interop.Excel
  2. Imports Office = Microsoft.Office.Core
  3.  
  4. Public Class Sheet1
  5. Private WithEvents myButton As New Button
  6. Private table As DataTable
  7.  
  8. Private Sub Sheet1_Startup(ByVal sender As Object, _
  9. ByVal e As System.EventArgs) Handles Me.Startup
  10.  
  11. myButton.Text = "Databind!"
  12. Globals.ThisWorkbook.ActionsPane.Controls.Add(myButton)
  13.  
  14. End Sub
  15.  
  16. Private Sub myButton_Click(ByVal sender As Object, _
  17. ByVal e As EventArgs) Handles myButton.Click
  18.  
  19. List1.DataSource = Nothing
  20. table = New DataTable
  21. Dim r As New Random
  22.  
  23. For i As Integer = To
  24. table.Columns.Add("Col" & i.ToString())
  25. Next
  26.  
  27. For j As Integer = To
  28. table.Rows.Add(r.NextDouble(), r.NextDouble(), _
  29. r.NextDouble(), r.NextDouble())
  30. Next
  31.  
  32. List1.DataSource = table
  33.  
  34. End Sub
  35. End Class

实例代码:

  1. Imports Excel = Microsoft.Office.Interop.Excel
  2. Imports Office = Microsoft.Office.Core
  3.  
  4. Public Class Sheet1
  5. Private WithEvents myButton As New Button 'WithEvents的意思是告知VB编译器这是一个可以触发事件对象
  6. Private table As DataTable 'DataTableExcel对象的
  7.  
  8. Private Sub Sheet1_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup
  9. myButton.Text = "Databind!"
  10. Globals.ThisWorkbook.ActionsPane.Controls.Add(myButton)'Actionspane.Controls表示右侧的文档操作面板
  11. End Sub
  12.  
  13. Private Sub myButton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles myButton.Click
  14. List1.DataSource = Nothing '设置数据源为空
  15. table = New DataTable '定义数据表用关键字new,实质就是一个实例对象
  16. Dim r As New Random '定义随机数用new关键字,实质就是一实例对象
  17. For i As Integer = To
  18. table.Columns.Add("Col" & i.ToString())
  19. Next
  20. For j As Integer = To
  21. table.Rows.Add(r.NextDouble(), r.NextDouble(), r.NextDouble(), r.NextDouble())'NextDouble大于或等于 0且小于 1 的随机浮点数
  22. Next
  23. List1.DataSource = table
  24. End Sub
  25. End Class

代码另一种写法:

  1. Imports Excel = Microsoft.Office.Interop.Excel
  2. Imports Office = Microsoft.Office.Core
  3.  
  4. Public Class Sheet1
  5. Private WithEvents myButton As New Button
  6. Private table As DataTable = New DataTable
  7. Dim r As New Random
  8.  
  9. Private Sub Sheet1_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup
  10. myButton.Text = "Databind!"
  11. Globals.ThisWorkbook.ActionsPane.Controls.Add(myButton)
  12. End Sub
  13.  
  14. Private Sub myButton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles myButton.Click
  15. List1.DataSource = Nothing
  16. table.Columns.Add() : table.Columns.Add() : table.Columns.Add() : table.Columns.Add() '添加4列,冒号接续
  17. For j As Integer = To
  18. table.Rows.Add(r.NextDouble(), r.NextDouble(), r.NextDouble(), r.NextDouble()) '生成194列的数据
  19. Next
  20. List1.DataSource = table '将table中的值作为数据源

Dim str As String
         str = table.Rows(2).Item(1).ToString() 'Rows(2).Item(1)表示第3行第2列,索引从0开始
         MsgBox(str)

  1. End Sub
  2. End Class

实例效果:

VSTO开发指南(VB2013版) 第二章 Office解决方案介绍的更多相关文章

  1. VSTO开发指南(VB2013版) 第一章 Office对象模型

    完美地将visual basic和office 办公软件结合起来.来自微软公司VSTO小组的权威专家所编著. 全书共712页,内容极其全面而深入,猛一看,厚地犹如庞然大物.看完离大神就不远了哦< ...

  2. 《NodeJs开发指南》第五章微博开发实例的中文乱码问题

    在<NodeJs开发指南>第五章,按照书中的要求写好微博实例后,运行代码,发现中文显示出现乱码,原因是:views文件夹下的ejs文件的编码格式不是utf-8. 解决方法:以记事本方式打开 ...

  3. 《Getting Started with WebRTC》第二章 WebRTC技术介绍

    <Getting Started with WebRTC>第二章 WebRTC技术介绍 本章作WebRTC的技术介绍,主要讲下面的概念:   .  怎样建立P2P的通信   .  有效的信 ...

  4. 《NodeJS开发指南》第五章微博实例开发总结

    所有文章搬运自我的个人主页:sheilasun.me <NodeJS开发指南>这本书用来NodeJS入门真是太好了,而且书的附录部分还讲到了闭包.this等JavaScript常用特性.第 ...

  5. Pro ASP.NET Core MVC 第6版 第二章(后半章)

    增加动态输出 整个web应用平台的关注点在于构建并显示动态输出内容.在MVC里,控制器负责构建一些数据并将其传给视图.视图负责渲染成HTML. 从控制器向视图传递数据的一种方式是使用ViewBag 对 ...

  6. Pro ASP.NET Core MVC 第6版 第二章(前半章)

    目录 第二章 第一个MVC 应用程序 学习一个软件开发框架的最好方法是跳进他的内部并使用它.在本章,你将用ASP.NET Core MVC创建一个简单的数据登录应用.我将它一步一步地展示,以便你能看清 ...

  7. Spring 3.x 实践 第一个例子(Spring 3.x 企业应用开发实战读书笔记第二章)

    前言:工作之后一直在搞android,现在需要更多和后台的人员交涉,技术栈不一样,难免鸡同鸭讲,所以稍稍学习下. 这个例子取自于<Spring 3.x 企业应用开发实战>一书中的第二章,I ...

  8. 《JS权威指南学习总结--第二章词法结构》

    第二章词法结构 内容要点: 一.注释 1. //表示单行注释 2. /*这里是一段注释*/ 3.一般编辑器里加注释是:选中要加注释的语句,按 ctrl+/ 二.直接量 所谓直接量,就是程序中直接使用的 ...

  9. Python核心编程第三版第二章学习笔记

    第二章 网络编程 1.学习笔记 2.课后习题 答案是按照自己理解和查阅资料来的,不保证正确性.如由错误欢迎指出,谢谢 1. 套接字:A network socket is an endpoint of ...

随机推荐

  1. Java入门 - 高级教程 - 07.多线程

    原文地址:http://www.work100.net/training/java-multi-threading.html 更多教程:光束云 - 免费课程 多线程 序号 文内章节 视频 1 概述 2 ...

  2. 「 Android开发 」开启第一个App应用

    每天进步一丢丢,连接梦与想 无论什么时候,永远不要以为自己知道一切   -巴普洛夫 最近玩了下Android,但遇到了一些坑,浪费了很多的时间,在此记录一下,你若是遇到了就知道怎么解决了 PS:建议使 ...

  3. idea怎么关闭项目

    原文地址:https://jingyan.baidu.com/article/a3a3f8112169e78da2eb8a8d.html idea关闭项目可以按File-CloseProject按钮实 ...

  4. 一题多解——Strategic Game

    点击打开题目 题目大意:给定一棵无根树,点亮其中某些点,使得这棵树的所有边都连接着一个以上的点亮的点 贪心中比较有挑战的题 由于如果点亮叶节点,就只会照亮一条边,但点亮它的父亲,就可以照亮除此边以外的 ...

  5. [校内训练20_01_17]ABC

    1.平面上每次加入直角边平行于坐标轴的等腰直角三角形,每次询问某个点被覆盖了多少次. 大常数算法:O(nlog^2) #include<bits/stdc++.h> using names ...

  6. Shell之作业控制

    命令 含义 jobs 列出所有正在运行的作业 ^Z(Ctrl+z) 暂停作业 bg 启动被暂停的作业 fg 将后台作业调到前台 kill 向指定作业发送kill信号 nohup 忽略所有发送给子命令的 ...

  7. Boyer-Moore 算法 Leetcode169

    Boyer-Moore 算法 Leetcode169 一.题目 169. 多数元素 给定一个大小为 n 的数组,找到其中的多数元素.多数元素是指在数组中出现次数大于 ⌊ n/2 ⌋ 的元素. 你可以假 ...

  8. abp vnext2.0核心组件之.Net Core默认DI组件切换到AutoFac源码解析

    老版Abp对Castle的严重依赖在vnext中已经得到了解决,vnext中DI容器可以任意更换,为了实现这个功能,底层架构相较于老版abp,可以说是进行了高度重构.当然这得益于.Net Core的D ...

  9. Linux文件和目录权限实战讲解

    一 相关课程回顾1.1 linux文件类型当执行ls -l或ls -la 命令后显示的结果中最前面的第2~10个字符是用来表示文件权限 第一个字符一般用来区分文件和目录: d:表示是一个目录,事实上在 ...

  10. 拖延症?贪玩?来试试"百万金币时间管理法"

    中午吃完饭就想休息? 一到假期就起不来? 总是想玩游戏? 究其原因是因为我们没有深刻意识到时间的价值. 这点在大气爱智慧的视频:懂这个道理,保证让你快速自律起来!拯救拖延症,更好的戒掉不良习惯中有讲到 ...