Skip to content

Commit f106465

Browse files
committed
Up
1 parent f89b999 commit f106465

30 files changed

Lines changed: 73318 additions & 1 deletion

ACSILCustomChartBars_Example.cpp

Lines changed: 444 additions & 0 deletions
Large diffs are not rendered by default.

ACSILSpreadsheetInteraction.cpp

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#include "sierrachart.h"
2+
3+
/*============================================================================
4+
Example study function for interacting with spreadsheets.
5+
----------------------------------------------------------------------------*/
6+
SCSFExport scsf_SpreadsheetInteractionExample(SCStudyInterfaceRef sc)
7+
{
8+
SCSubgraphRef Subgraph_FormulaResult = sc.Subgraph[0];
9+
10+
if (sc.SetDefaults)
11+
{
12+
// Set the configuration and defaults
13+
14+
sc.GraphName = "Spreadsheet Interaction Example";
15+
16+
sc.StudyDescription
17+
= "This is an example study for demonstrating how to interact with spreadsheets from ACSIL. This example requires an open sheet collection name \"ACSILInteractionExample\".";
18+
19+
sc.AutoLoop = 0;
20+
21+
Subgraph_FormulaResult.Name = "Formula Result";
22+
Subgraph_FormulaResult.DrawZeros = true;
23+
24+
return;
25+
}
26+
27+
// This can either contain a complete path and file extension, or just
28+
// the name of the spreadsheet file itself without the extension.
29+
const char* SheetCollectionName = "ACSILInteractionExample";
30+
31+
sc.OpenSpreadsheet(SheetCollectionName);
32+
33+
const char* SheetName = "Sheet1";
34+
35+
void* SheetHandle = sc.GetSpreadsheetSheetHandleByName(SheetCollectionName, SheetName, false);
36+
37+
// Note: The Column and Row parameters are zero-based indexes, so column
38+
// 'A' is index 0, and row '1' is index 0.
39+
40+
// Set labels in column A.
41+
sc.SetSheetCellAsString(SheetHandle, 0, 1, "High");
42+
sc.SetSheetCellAsString(SheetHandle, 0, 2, "Low");
43+
sc.SetSheetCellAsString(SheetHandle, 0, 3, "Enter Formula");
44+
sc.SetSheetCellAsString(SheetHandle, 0, 5, "Log Message");
45+
46+
// Set values in column B.
47+
sc.SetSheetCellAsDouble(SheetHandle, 1, 1, sc.BaseData[SC_HIGH][sc.Index]);
48+
sc.SetSheetCellAsDouble(SheetHandle, 1, 2, sc.BaseData[SC_LOW][sc.Index]);
49+
50+
// Get the result from cell B4. Column and row indexes are zero-based.
51+
double CellValue = 0.0;
52+
sc.GetSheetCellAsDouble(SheetHandle, 1, 3, CellValue);
53+
54+
// Set the result into a subgraph.
55+
Subgraph_FormulaResult[sc.Index] = static_cast<float>(CellValue);
56+
57+
// Get the text from cell B6, if it exists, and add it to the message log.
58+
SCString CellString;
59+
if (sc.GetSheetCellAsString(SheetHandle, 1, 5, CellString))
60+
sc.AddMessageToLog(CellString, 0);
61+
}
62+
63+
/*==========================================================================*/

0 commit comments

Comments
 (0)