![]() |
Edit |
![]() |
|
![]() |
Recent Changes |
![]() |
Subscriptions |
![]() |
Lost and Found |
![]() |
Find References |
![]() |
Rename |
| Search |
![]() |
List all versions |
Here is an example of an Excel "pipe", e.g. excel used as a data sink:
Example usage :
let e = excel ;;
let wb = workbook e;;
let ws = sheet wb;;
let rng = new Random();;
(CompatArray.init 10 (fun i -> rng.NextDouble()) ) |> xl_dump ws 10 10 ;;
Main program :
#r "Microsoft.Office.Interop.Excel.dll";;
open System
open System.Reflection (* For Missing.Value and BindingFlags *)
open System.Runtime.InteropServices (* For COMException *)
open Microsoft.Office.Interop.Excel
module CompatArray = Microsoft.FSharp.Compatibility.CompatArray
module CompatMatrix = Microsoft.FSharp.Compatibility.CompatMatrix
let excel =
let app = new ApplicationClass() in
let _ = app.Visible <- true in
app;;
let workbook (excel : ApplicationClass) =
let workbooks = excel.Workbooks in
let wb = workbooks.Add(XlWBATemplate.xlWBATWorksheet) in
wb;;
let sheet (workbook : Workbook) =
let sheets = workbook.Worksheets in
let sh = (sheets.Item(1) :?> _Worksheet) in
sh;;
let xl_dump (worksheet : _Worksheet) x1 y1 data =
let cell1 = worksheet.Cells.Item(x1,y1) in
let size = CompatArray.length data in
let cellN = worksheet.Cells.Item(x1 ,y1 +size -1) in
let target_range = worksheet.Range(cell1,cellN) in
let _ = target_range.Value2 <- (CompatArray.of_array data) in
();;
![]() |
| This site supports the new NoFollow anti-spam initiative. |
Recent Topics