pub struct MacroContext<'call> { /* private fields */ }Expand description
Capability token for a genuine macro/command callback.
It is callback-borrowed and must not be retained or sent to another thread. The ordinary build exposes no xlcOnTime scheduling operation:
use excel_api::MacroContext;
fn no_production_ontime(context: &MacroContext<'_>) {
let _ = context.experimental_schedule_on_time(45_000.0, "COMMAND");
}Implementations§
Source§impl MacroContext<'_>
impl MacroContext<'_>
Sourcepub fn drain_dispatcher(&self) -> DispatchDrainReport
pub fn drain_dispatcher(&self) -> DispatchDrainReport
Drains one bounded cooperative batch under this genuine macro callback.
Enqueueing a request does not invoke this method or otherwise wake Excel.
Source§impl<'call> MacroContext<'call>
impl<'call> MacroContext<'call>
Sourcepub fn active_sheet_id(&self) -> Result<u64, ExcelCallError>
pub fn active_sheet_id(&self) -> Result<u64, ExcelCallError>
Returns the internal ID of Excel’s active/front sheet.
This is deliberately not named “current”: the zero-argument
xlSheetId contract identifies the active/front sheet.
Sourcepub fn current_sheet_name(&self) -> Result<ExcelString, ExcelCallError>
pub fn current_sheet_name(&self) -> Result<ExcelString, ExcelCallError>
Returns the name of the current sheet, not the active sheet.
Source§impl<'call> MacroContext<'call>
impl<'call> MacroContext<'call>
Sourcepub fn is_cancellation_requested(&self) -> Result<bool, ExcelCallError>
pub fn is_cancellation_requested(&self) -> Result<bool, ExcelCallError>
Poll whether Excel has received a user cancellation/break request. This zero-argument form preserves a pending break request.
Sourcepub fn is_cancellation_requested_with(
&self,
mode: AbortCheckMode,
) -> Result<bool, ExcelCallError>
pub fn is_cancellation_requested_with( &self, mode: AbortCheckMode, ) -> Result<bool, ExcelCallError>
Poll cancellation while explicitly preserving or clearing a pending break.
Source§impl<'call> MacroContext<'call>
impl<'call> MacroContext<'call>
Sourcepub fn caller(&self) -> Result<ExcelOwnedValue<'call>, ExcelCallError>
pub fn caller(&self) -> Result<ExcelOwnedValue<'call>, ExcelCallError>
Returns Excel’s caller value with its Excel-owned result lifetime.
Source§impl<'call> MacroContext<'call>
impl<'call> MacroContext<'call>
Sourcepub fn coerce(
&self,
source: &ExcelOwnedValue<'call>,
target: CoerceTarget,
) -> Result<ExcelOwnedValue<'call>, ExcelCallError>
pub fn coerce( &self, source: &ExcelOwnedValue<'call>, target: CoerceTarget, ) -> Result<ExcelOwnedValue<'call>, ExcelCallError>
Converts an Excel-owned callback result to a requested root type.
The source remains owned by the caller and is not consumed or
released by xlCoerce; the returned root has its own xlFree
obligation encoded in ExcelOwnedValue.