在进行EXCEL报表系统开发,每次将EXCEL表格从数据库中读出并在临时文件夹生成EXCEL文件再让EXCEL读取,保存时在读取为数据流存入数据库,中间有两次读写盘对速度有影响突然想到为什么不能从数据流直接注入EXCEL中呢?自己试验使用ReadProcessMemory、WriteProcessMemory连内存数据也没读到,请高人帮忙。
目前最高100,发帖后再加分或别外开贴加分。
------解决方案--------------------
EXCEL有特殊格式,你在内存如何读写
*****************************************************************************
欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码)
http://feiyun0112.cnblogs.com/
------解决方案--------------------
帮顶,学习
------解决方案--------------------
没有试过读取内存中的数据,学习!
------解决方案--------------------
没明白LZ所说
------解决方案--------------------
顶下,,
------解决方案--------------------
注入到EXCEL进和读出EXCEL内存数据流之间有数据操作吗?
------解决方案--------------------
你就是说
1、从数据库读取数据
2、保存到EXCEL文件
3、从EXCEL文件读取数据
4、保存到数据库
不知是否是上面的流程?
------解决方案--------------------
帮顶。。。给分。呵呵
------解决方案--------------------
EXCEL 导入 SQL 的方法
- SQL code
SELECT * FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0', 'Data Source="c:\Finance\account.xls";User ID=Admin;Password=;Extended properties=Excel 5.0')...[Sheet1$]
------解决方案--------------------
根据站点所在机器的EXCEL版本替换上面的版本
------解决方案--------------------
帮顶有分么?那就顶一个。
------解决方案--------------------
------解决方案--------------------
不知道怎样读取在内存中的EXCEL数据流,只知道文本流。不懂!
学习+接分 o(∩_∩)o...哈哈
------解决方案--------------------
这是一个老外写的不需要安装EXCEL就可以创建EXCEL文件的类,可能对你有帮助。
- VB.NET code
Public Enum ValueTypes xlsInteger = 0 xlsNumber = 1 xlsText = 2 End Enum 'enum to hold cell alignment Public Enum CellAlignment xlsGeneralAlign = 0 xlsLeftAlign = 1 xlsCentreAlign = 2 xlsRightAlign = 3 xlsFillCell = 4 xlsLeftBorder = 8 xlsRightBorder = 16 xlsTopBorder = 32 xlsBottomBorder = 64 xlsShaded = 128 End Enum 'enum to handle selecting the font for the cell Public Enum CellFont 'used by rgbAttr2 'bits 0-5 handle the *picture* formatting, not bold/underline etc... 'bits 6-7 handle the font number xlsFont0 = 0 xlsFont1 = 64 xlsFont2 = 128 xlsFont3 = 192 End Enum Public Enum CellHiddenLocked 'used by rgbAttr1 'bits 0-5 must be zero 'bit 6 locked/unlocked 'bit 7 hidden/not hidden xlsNormal = 0 xlsLocked = 64 xlsHidden = 128 End Enum 'set up variables to hold the spreadsheet's layout Public Enum MarginTypes xlsLeftMargin = 38 xlsRightMargin = 39 xlsTopMargin = 40 xlsBottomMargin = 41 End Enum Public Enum FontFormatting 'add these enums together. For example: xlsBold + xlsUnderline xlsNoFormat = 0 xlsBold = 1 xlsItalic = 2 xlsUnderline = 4 xlsStrikeout = 8 End Enum Private Structure FONT_RECORD Dim opcode As Short '49 Dim length As Short '5+len(fontname) Dim FontHeight As Short 'bit0 bold, bit1 italic, bit2 underline, bit3 strikeout, bit4-7 reserved Dim FontAttributes1 As Byte Dim FontAttributes2 As Byte 'reserved - always 0 Dim FontNameLength As Byte End Structure Private Structure PASSWORD_RECORD Dim opcode As Short '47 Dim length As Short 'len(password) End Structure Private Structure HEADER_FOOTER_RECORD Dim opcode As Short '20 Header, 21 Footer Dim length As Short '1+len(text) Dim TextLength As Byte End Structure Private Structure PROTECT_SPREADSHEET_RECORD Dim opcode As Short '18 Dim length As Short '2 Dim Protect As Short End Structure Private Structure FORMAT_COUNT_RECORD Dim opcode As Short '1f Dim length As Short '2 Dim Count As Short End Structure Private Structure FORMAT_RECORD Dim opcode As Short '1e Dim length As Short '1+len(format) Dim FormatLenght As Byte 'len(format) End Structure '+ followed by the Format-Picture Private Structure COLWIDTH_RECORD Dim opcode As Short '36 Dim length As Short '4 Dim col1 As Byte 'first column Dim col2 As Byte 'last column Dim ColumnWidth As Short 'at 1/256th of a character End Structure 'Beginning Of File record Private Structure BEG_FILE_RECORD Dim opcode As Short Dim length As Short Dim version As Short Dim ftype As Short End Structure 'End Of File record Private Structure END_FILE_RECORD Dim opcode As Short Dim length As Short End Structure 'true/false to print gridlines Private Structure PRINT_GRIDLINES_RECORD Dim opcode As Short Dim length As Short Dim PrintFlag As Short End Structure 'Integer record Private Structure tInteger Dim opcode As Short Dim length As Short Dim row As Short 'unsigned integer Dim col As Short 'rgbAttr1 handles whether cell is hidden and/or locked Dim rgbAttr1 As Byte 'rgbAttr2 handles the Font# and Formatting assigned to this cell Dim rgbAttr2 As Byte 'rgbAttr3 handles the Cell Alignment/borders/shading Dim rgbAttr3 As Byte Dim intValue As Short 'the actual integer value End Structure 'Number record Private Structure tNumber Dim opcode As Short Dim length As Short Dim row As Short Dim col As Short Dim rgbAttr1 As Byte Dim rgbAttr2 As Byte Dim rgbAttr3 As Byte Dim NumberValue As Double '8 Bytes End Structure 'Label (Text) record Private Structure tText Dim opcode As Short Dim length As Short Dim row As Short Dim col As Short Dim rgbAttr1 As Byte Dim rgbAttr2 As Byte Dim rgbAttr3 As Byte Dim TextLength As Byte End Structure Private Structure MARGIN_RECORD_LAYOUT Dim opcode As Short Dim length As Short Dim MarginValue As Double '8 bytes End Structure Private Structure HPAGE_BREAK_RECORD Dim opcode As Short Dim length As Short Dim NumPageBreaks As Short End Structure Private Structure DEF_ROWHEIGHT_RECORD Dim opcode As Integer Dim length As Integer Dim RowHeight As Integer End Structure Private Structure ROW_HEIGHT_RECORD Dim opcode As Integer '08 Dim length As Integer 'should always be 16 bytes Dim RowNumber As Integer Dim FirstColumn As Integer Dim LastColumn As Integer Dim RowHeight As Integer 'written to file as 1/20ths of a point Dim internal As Integer Dim DefaultAttributes As Byte 'set to zero for no default attributes Dim FileOffset As Integer Dim rgbAttr1 As Byte Dim rgbAttr2 As Byte Dim rgbAttr3 As Byte End Structure 'the memory copy API is used in the MKI$ function which converts an integer 'value to a 2-byte string value to write to the file. (used by the Horizontal 'Page Break function). Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByRef lpvDest As String, ByRef lpvSource As Short, ByVal cbCopy As Integer) Private m_shtFileNumber As Short Private m_udtBEG_FILE_MARKER As BEG_FILE_RECORD Private m_udtEND_FILE_MARKER As END_FILE_RECORD Private m_udtHORIZ_PAGE_BREAK As HPAGE_BREAK_RECORD 'create an array that will hold the rows where a horizontal page 'break will be inserted just before. Private m_shtHorizPageBreakRows() As Short Private m_shtNumHorizPageBreaks As Short