quantumgrid

How to paste data from Excel into cxGrid

时光怂恿深爱的人放手 提交于 2019-12-23 01:20:31
问题 I have a Delphi application using DevExpress cxGrid (which is connected to database). I require to be able to copy-paste data from Excel into the grid. Is this possible? If so, how to do it, which additional components do i need? 回答1: Check the format with Clipboard.HasFormat(CF_TEXT) . Extract the text with Clipboard.AsText . Split into rows with StringList.Text := Clipboard.AsText . Each item in the string list is now a row from the clipboard. Split each row into individual cells using a

How to paste data from Excel into cxGrid

时光毁灭记忆、已成空白 提交于 2019-12-06 14:36:28
I have a Delphi application using DevExpress cxGrid (which is connected to database). I require to be able to copy-paste data from Excel into the grid. Is this possible? If so, how to do it, which additional components do i need? Check the format with Clipboard.HasFormat(CF_TEXT) . Extract the text with Clipboard.AsText . Split into rows with StringList.Text := Clipboard.AsText . Each item in the string list is now a row from the clipboard. Split each row into individual cells using a Split function: function Split(const s: string; Separator: char): TStringDynArray; var i, ItemIndex: Integer;

How do I set Excel column types and formatting?

天大地大妈咪最大 提交于 2019-11-28 08:17:55
问题 I'm exporting data from a CxDBGrid to an Excel file. I'm able to create the file and copy data in it, but I'm having real trouble with the column formatting. Since I'm pulling the data from a DB I'd like the spreadsheet to reflect the type: NUMBER, VARCHAR2,DATE and so on. I visually created a macro, went to look for the VBA code, and replicated it in the Delphi project: sheet.Columns[K+2].NumberFormat := '0,000'; //Number sheet.Columns[K+2].NumberFormat := '@'; //Text sheet.Columns[K+2]