use xladd::registrator::Reg; use xladd::variant::Variant; use xladd::xlcall::LPXLOPER12; use xladd_derive::xl_func; #[xl_func()] fn add(arg1: f64, arg2: f64) -> Result> { Ok(arg1 + arg2) } /// This function adds any number of values together /// * v - array of f64 /// * ret - returns the sum0 #[xl_func()] fn add_array(v: &[f64]) -> Result> { Ok(v.iter().sum()) } /// This function adds any number of values together /// * v - array of f64 /// * ret - returns the sum #[xl_func()] fn add_array_v2(v: &[f64]) -> Result<(Vec, usize), Box> { Ok((v.to_vec(), 2)) } /// This function adds any number of values together /// * v - array of f64 /// * ret - returns the sum #[xl_func()] fn add_str(a: &str, b: &str) -> Result> { Ok([a, b].join("-")) } #[xl_func(category = "OptionPricing", prefix = "my", rename = "foo")] fn add_str_2(a: &[&str]) -> Result<(Vec, usize), Box> { Ok((vec![a.join("-")], 1)) } #[cfg(feature = "use_ndarray")] use ndarray::Array2; #[cfg(feature = "use_ndarray")] #[xl_func(category = "OptionPricing", prefix = "my", rename = "bar")] fn add_str_3(a: Array2) -> Result, Box> { Ok(Array2::from_elem([2, 2], 0.0f64)) } #[cfg(feature = "use_ndarray")] #[xl_func(category = "OptionPricing", prefix = "my", rename = "baz")] fn add_f64_2(a: Array2) -> Result, Box> { Ok(Array2::from_elem([2, 2], 0.0f64)) } // Don't forget to register your functions #[no_mangle] pub extern "stdcall" fn xlAutoOpen() -> i32 { let r = Reg::new(); #[cfg(feature = "use_ndarray")] register_add_f64_2(&r); 1 } fn main() {} // Not needed for actual dll