Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9c2153c

Browse files
add new code snippets
1 parent af002a8 commit 9c2153c

File tree

16 files changed

+321
-70
lines changed

16 files changed

+321
-70
lines changed
5.5 KB
Loading[フレーム]

‎CS/SpreadsheetExamples/Form1.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ void InitData(GroupsOfSpreadsheetExamples examples) {
6666
examples[2].Groups.Add(new SpreadsheetExample("Add a Hyperlink to a Cell", CellActions.AddHyperlinkAction));
6767
examples[2].Groups.Add(new SpreadsheetExample("Copy Data Only, Style Only, or Data with Style", CellActions.CopyCellDataAndStyleAction));
6868
examples[2].Groups.Add(new SpreadsheetExample("Merge/Split Cells", CellActions.MergeAndSplitCellsAction));
69+
examples[2].Groups.Add(new SpreadsheetExample("Place Image in a Cell", CellActions.PlaceImageInCellAction));
6970
examples[2].Groups.Add(new SpreadsheetExample("Clear Cells", CellActions.ClearCellsAction));
7071

7172
// Add nodes to the "Formulas" group of examples.
@@ -74,7 +75,8 @@ void InitData(GroupsOfSpreadsheetExamples examples) {
7475
examples[3].Groups.Add(new SpreadsheetExample("Names in Formulas", FormulaActions.UseNamesInFormulasAction));
7576
examples[3].Groups.Add(new SpreadsheetExample("Create Named Formulas", FormulaActions.CreateNamedFormulasAction));
7677
examples[3].Groups.Add(new SpreadsheetExample("Functions in Formulas", FormulaActions.UseFunctionsInFormulasAction));
77-
examples[3].Groups.Add(new SpreadsheetExample("Shared and Array Formulas", FormulaActions.CreateSharedAndArrayFormulasAction));
78+
examples[3].Groups.Add(new SpreadsheetExample("Shared and Legacy Array Formulas", FormulaActions.CreateSharedAndArrayFormulasAction));
79+
examples[3].Groups.Add(new SpreadsheetExample("Dynamic Array Formulas", FormulaActions.CreateDynamicArrayFormulasAction));
7880

7981
// Add nodes to the "Formatting" group of examples.
8082
examples[4].Groups.Add(new SpreadsheetExample("Apply a Style", FormattingActions.ApplyStyleAction));

‎CS/SpreadsheetExamples/Properties/Resources.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎CS/SpreadsheetExamples/Properties/Settings.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎CS/SpreadsheetExamples/SpreadsheetActions/CellActions.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
using System.Drawing;
33
using DevExpress.Spreadsheet;
44
using System.Collections.Generic;
5+
using DevExpress.Pdf.Native.BouncyCastle.Asn1.BC;
6+
using System.IO;
7+
using System.IO.Ports;
58

69
namespace SpreadsheetExamples {
710
public static class CellActions {
@@ -11,6 +14,7 @@ public static class CellActions {
1114
public static Action<IWorkbook> SetValueFromTextAction = SetValueFromText;
1215
public static Action<Workbook> CreateNamedRangeAction = CreateNamedRange;
1316
public static Action<Workbook> AddHyperlinkAction = AddHyperlink;
17+
public static Action<Workbook> PlaceImageInCellAction = PlaceImageInCell;
1418
public static Action<Workbook> CopyCellDataAndStyleAction = CopyCellDataAndStyle;
1519
public static Action<Workbook> MergeAndSplitCellsAction = MergeAndSplitCells;
1620
public static Action<Workbook> ClearCellsAction = ClearCells;
@@ -191,6 +195,29 @@ static void MergeAndSplitCells(Workbook workbook) {
191195
#endregion #MergeCells
192196
}
193197

198+
static void PlaceImageInCell(Workbook workbook)
199+
{
200+
#region #PlaceImageInCell
201+
Worksheet worksheet = workbook.Worksheets.ActiveWorksheet;
202+
203+
byte[] imageBytes = File.ReadAllBytes(@"Documents\x-docserver.png");
204+
MemoryStream imageStream = new MemoryStream(imageBytes);
205+
206+
worksheet.Cells["A2"].ColumnWidthInCharacters = 20;
207+
// Insert cell images from a stream
208+
worksheet.Cells["A2"].Value = imageStream;
209+
210+
// Specify image information
211+
if (worksheet.Cells["A2"].Value.IsCellImage)
212+
{
213+
worksheet.Cells["A2"].ImageInfo.Decorative = true;
214+
worksheet.Cells["A2"].ImageInfo.AlternativeText = "Image AltText";
215+
}
216+
#endregion #PlaceImageInCell
217+
218+
219+
}
220+
194221
static void ClearCells(Workbook workbook) {
195222
Worksheet worksheet = workbook.Worksheets[0];
196223

‎CS/SpreadsheetExamples/SpreadsheetActions/FormulaActions.cs

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
using System;
2-
using DevExpress.Spreadsheet;
1+
using DevExpress.Spreadsheet;
2+
using System;
33
using System.Drawing;
44

5-
namespace SpreadsheetExamples {
6-
public static class FormulaActions {
5+
namespace SpreadsheetExamples
6+
{
7+
public static class FormulaActions
8+
{
79

810
#region Actions
911
public static Action<Workbook> UseConstantsAndCalculationOperatorsInFormulasAction = UseConstantsAndCalculationOperatorsInFormulas;
@@ -12,9 +14,11 @@ public static class FormulaActions {
1214
public static Action<Workbook> CreateNamedFormulasAction = CreateNamedFormulas;
1315
public static Action<Workbook> UseFunctionsInFormulasAction = UseFunctionsInFormulas;
1416
public static Action<Workbook> CreateSharedAndArrayFormulasAction = CreateSharedAndArrayFormulas;
17+
public static Action<Workbook> CreateDynamicArrayFormulasAction = CreateDynamicArrayFormulas;
1518
#endregion
1619

17-
static void UseConstantsAndCalculationOperatorsInFormulas(Workbook workbook) {
20+
static void UseConstantsAndCalculationOperatorsInFormulas(Workbook workbook)
21+
{
1822
Worksheet worksheet = workbook.Worksheets[0];
1923

2024
worksheet.Cells["A1"].Value = "Formula";
@@ -28,7 +32,8 @@ static void UseConstantsAndCalculationOperatorsInFormulas(Workbook workbook) {
2832
#endregion #ConstantsAndCalculationOperators
2933
}
3034

31-
static void R1C1ReferencesInFormulas(Workbook workbook) {
35+
static void R1C1ReferencesInFormulas(Workbook workbook)
36+
{
3237
Worksheet worksheet = workbook.Worksheets[0];
3338

3439
// Fill cells with static data.
@@ -64,7 +69,8 @@ static void R1C1ReferencesInFormulas(Workbook workbook) {
6469
#endregion #R1C1ReferencesInFormulas
6570
}
6671

67-
static void UseNamesInFormulas(Workbook workbook) {
72+
static void UseNamesInFormulas(Workbook workbook)
73+
{
6874
Worksheet worksheet = workbook.Worksheets[0];
6975

7076
CellRange dataRangeHeader = worksheet.Range["A1:C1"];
@@ -144,7 +150,8 @@ static void CreateNamedFormulas(Workbook workbook)
144150
workbook.Worksheets.ActiveWorksheet = workbook.Worksheets["Sheet2"];
145151
}
146152

147-
static void UseFunctionsInFormulas(Workbook workbook) {
153+
static void UseFunctionsInFormulas(Workbook workbook)
154+
{
148155
Worksheet worksheet = workbook.Worksheets[0];
149156
// Fill cells with static data.
150157
worksheet.Cells["A1"].Value = "Data";
@@ -182,7 +189,7 @@ static void UseFunctionsInFormulas(Workbook workbook) {
182189
// Use a nested function in a formula.
183190
// Round the sum of the values contained in the "A6" and "A7" cells to two decimal places.
184191
worksheet.Cells["C5"].Formula = "=ROUND(SUM(A6,A7),2)";
185-
192+
186193
// Add the current date to the "C6" cell.
187194
worksheet.Cells["C6"].Formula = "=Today()";
188195
worksheet.Cells["C6"].NumberFormat = "m/d/yy";
@@ -192,7 +199,8 @@ static void UseFunctionsInFormulas(Workbook workbook) {
192199
#endregion #FunctionsInFormulas
193200
}
194201

195-
static void CreateSharedAndArrayFormulas(Workbook workbook) {
202+
static void CreateSharedAndArrayFormulas(Workbook workbook)
203+
{
196204
Worksheet worksheet = workbook.Worksheets[0];
197205

198206
worksheet.Range["A1:D1"].ColumnWidthInCharacters = 10;
@@ -231,12 +239,31 @@ static void CreateSharedAndArrayFormulas(Workbook workbook) {
231239

232240
// Re-dimension an array formula range:
233241
// delete the array formula and create a new range with the same formula.
234-
if (worksheet.Cells["C13"].HasArrayFormula) {
242+
if (worksheet.Cells["C13"].HasArrayFormula)
243+
{
235244
string af = worksheet.Cells["C13"].ArrayFormula;
236245
worksheet.Cells["C13"].GetArrayFormulaRange().ArrayFormula = string.Empty;
237246
worksheet.Range["C2:C11"].ArrayFormula = af;
238247
}
239248
#endregion #ArrayFormulas
240249
}
250+
251+
static void CreateDynamicArrayFormulas(Workbook workbook)
252+
{
253+
#region #DynamicArrayFormulas
254+
Worksheet worksheet = workbook.Worksheets[0];
255+
256+
worksheet.Range["A1"].ColumnWidthInCharacters = 20;
257+
worksheet.Range["A1"].Alignment.Horizontal = SpreadsheetHorizontalAlignment.Center;
258+
worksheet.Range["A1"].FillColor = Color.LightGray;
259+
260+
worksheet.Range["A1"].Value = "Dynamic Array Formulas:";
261+
262+
263+
// Insert dynamic array formulas
264+
worksheet["A2"].DynamicArrayFormulaInvariant = "={\"Red\",\"Green\",\"Orange\",\"Blue\"}";
265+
worksheet.DynamicArrayFormulas.Add(worksheet["B1"], "=LEN(A2:D2)");
266+
#endregion #DynamicArrayFormulas
267+
}
241268
}
242269
}

‎CS/SpreadsheetExamples/SpreadsheetExamples.csproj

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
<AppDesignerFolder>Properties</AppDesignerFolder>
1111
<RootNamespace>SpreadsheetExamples</RootNamespace>
1212
<AssemblyName>SpreadsheetExamples</AssemblyName>
13-
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
14-
<TargetFrameworkProfile></TargetFrameworkProfile>
13+
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
14+
<TargetFrameworkProfile>
15+
</TargetFrameworkProfile>
1516
<FileAlignment>512</FileAlignment>
1617
</PropertyGroup>
1718
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
@@ -147,6 +148,11 @@
147148
<DesignTimeSharedInput>True</DesignTimeSharedInput>
148149
</Compile>
149150
</ItemGroup>
151+
<ItemGroup>
152+
<Content Include="Documents\x-docserver.png">
153+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
154+
</Content>
155+
</ItemGroup>
150156
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
151157
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
152158
Other similar extension points exist, see Microsoft.Common.targets.

‎CS/SpreadsheetExamples/app.config

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,51 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
3+
<configSections>
4+
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System">
5+
<section name="DevExpress.LookAndFeel.Design.AppSettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
6+
</sectionGroup>
7+
</configSections>
8+
<applicationSettings>
9+
<DevExpress.LookAndFeel.Design.AppSettings>
10+
<setting name="DefaultAppSkin" serializeAs="String">
11+
<value></value>
12+
</setting>
13+
<setting name="DefaultPalette" serializeAs="String">
14+
<value></value>
15+
</setting>
16+
<setting name="TouchUI" serializeAs="String">
17+
<value></value>
18+
</setting>
19+
<setting name="CompactUI" serializeAs="String">
20+
<value></value>
21+
</setting>
22+
<setting name="TouchScaleFactor" serializeAs="String">
23+
<value></value>
24+
</setting>
25+
<setting name="DirectX" serializeAs="String">
26+
<value></value>
27+
</setting>
28+
<setting name="RegisterUserSkins" serializeAs="String">
29+
<value></value>
30+
</setting>
31+
<setting name="RegisterBonusSkins" serializeAs="String">
32+
<value></value>
33+
</setting>
34+
<setting name="FontBehavior" serializeAs="String">
35+
<value></value>
36+
</setting>
37+
<setting name="DefaultAppFont" serializeAs="String">
38+
<value></value>
39+
</setting>
40+
<setting name="DPIAwarenessMode" serializeAs="String">
41+
<value>PerMonitorV2</value>
42+
</setting>
43+
<setting name="CustomPaletteCollection" serializeAs="Xml">
44+
<value />
45+
</setting>
46+
</DevExpress.LookAndFeel.Design.AppSettings>
47+
</applicationSettings>
348
<startup>
4-
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
49+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
550
</startup>
651
</configuration>
5.5 KB
Loading[フレーム]

‎VB/SpreadsheetExamples/Form1.vb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,16 @@ Namespace SpreadsheetExamples
6565
examples(2).Groups.Add(New SpreadsheetExample("Add a Hyperlink to a Cell", AddHyperlinkAction))
6666
examples(2).Groups.Add(New SpreadsheetExample("Copy Data Only, Style Only, or Data with Style", CopyCellDataAndStyleAction))
6767
examples(2).Groups.Add(New SpreadsheetExample("Merge/Split Cells", MergeAndSplitCellsAction))
68+
examples(2).Groups.Add(New SpreadsheetExample("Place Image in a Cell", PlaceImageInCellAction))
6869
examples(2).Groups.Add(New SpreadsheetExample("Clear Cells", ClearCellsAction))
6970
' Add nodes to the "Formulas" group of examples.
7071
examples(3).Groups.Add(New SpreadsheetExample("Constants and Calculation Operators in Formulas", UseConstantsAndCalculationOperatorsInFormulasAction))
7172
examples(3).Groups.Add(New SpreadsheetExample("R1C1 References in Formulas", R1C1ReferencesInFormulassAction))
7273
examples(3).Groups.Add(New SpreadsheetExample("Names in Formulas", UseNamesInFormulasAction))
7374
examples(3).Groups.Add(New SpreadsheetExample("Create Named Formulas", CreateNamedFormulasAction))
7475
examples(3).Groups.Add(New SpreadsheetExample("Functions in Formulas", UseFunctionsInFormulasAction))
75-
examples(3).Groups.Add(New SpreadsheetExample("Shared and Array Formulas", CreateSharedAndArrayFormulasAction))
76+
examples(3).Groups.Add(New SpreadsheetExample("Shared and Legacy Array Formulas", CreateSharedAndArrayFormulasAction))
77+
examples(3).Groups.Add(New SpreadsheetExample("Dynamic Array Formulas", CreateDynamicArrayFormulasAction))
7678
' Add nodes to the "Formatting" group of examples.
7779
examples(4).Groups.Add(New SpreadsheetExample("Apply a Style", ApplyStyleAction))
7880
examples(4).Groups.Add(New SpreadsheetExample("Create and Modify a Style", CreateModifyStyleAction))

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /