Skip to content

Commit 34cf45d

Browse files
Editable ranges
1 parent 4a924b7 commit 34cf45d

File tree

35 files changed

+675
-0
lines changed

35 files changed

+675
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.13.35825.156 d17.13
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Add-editable-range-in-a-table", "Add-editable-range-in-a-table\Add-editable-range-in-a-table.csproj", "{1DF5F92E-BE60-4875-A5F7-1363B43AF83A}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{1DF5F92E-BE60-4875-A5F7-1363B43AF83A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{1DF5F92E-BE60-4875-A5F7-1363B43AF83A}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{1DF5F92E-BE60-4875-A5F7-1363B43AF83A}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{1DF5F92E-BE60-4875-A5F7-1363B43AF83A}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {1FBCA517-BE3F-40EF-B53A-536B02603ECA}
24+
EndGlobalSection
25+
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Add_editable_range_in_a_table</RootNamespace>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Syncfusion.DocIO.Net.Core" Version="*" />
11+
</ItemGroup>
12+
13+
<ItemGroup>
14+
<None Update="Output\.gitkeep">
15+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
16+
</None>
17+
</ItemGroup>
18+
19+
</Project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
using Syncfusion.DocIO.DLS;
2+
using Syncfusion.DocIO;
3+
using System.IO;
4+
5+
namespace Add_editable_range_in_a_table
6+
{
7+
class Program
8+
{
9+
static void Main(string[] args)
10+
{
11+
//Creates a Word document
12+
using (WordDocument document = new WordDocument())
13+
{
14+
//Adds a section and a paragraph in the Word document
15+
document.EnsureMinimal();
16+
17+
//Adds a table
18+
WTable table = document.LastSection.AddTable() as WTable;
19+
table.ResetCells(2, 3);
20+
21+
//Access each table cell and append text
22+
table[0, 0].AddParagraph().AppendText("Row1 Col1");
23+
table[0, 1].AddParagraph().AppendText("Row1 Col2");
24+
table[0, 2].AddParagraph().AppendText("Row1 Col3");
25+
table[1, 0].AddParagraph().AppendText("Row2 Col1");
26+
table[1, 1].AddParagraph().AppendText("Row2 Col2");
27+
table[1, 2].AddParagraph().AppendText("Row2 Col3");
28+
29+
//Starts the editable range in a table cell
30+
EditableRangeStart editableRangeStart = table[0, 1].Paragraphs[0].AppendEditableRangeStart();
31+
32+
//Sets the first column where the editable range starts within a table
33+
editableRangeStart.EditableRange.FirstColumn = 1;
34+
35+
//Ends the ediatble range in a table cell
36+
EditableRangeEnd rangeEnd = table[1, 2].Paragraphs[0].AppendEditableRangeEnd(editableRangeStart);
37+
38+
//Sets the last column where the editable range ends within a table
39+
editableRangeStart.EditableRange.LastColumn = 2;
40+
41+
//Sets the protection with password and allows only reading
42+
document.Protect(ProtectionType.AllowOnlyReading, "password");
43+
44+
//Creates file stream
45+
using (FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Result.docx"), FileMode.Create, FileAccess.ReadWrite))
46+
{
47+
//Saves the Word document to file stream
48+
document.Save(outputStream, FormatType.Docx);
49+
}
50+
}
51+
}
52+
}
53+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.13.35825.156 d17.13
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Add-editable-range", "Add-editable-range\Add-editable-range.csproj", "{4B875FB3-1D7A-4C86-A1E7-BA77906674BF}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{4B875FB3-1D7A-4C86-A1E7-BA77906674BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{4B875FB3-1D7A-4C86-A1E7-BA77906674BF}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{4B875FB3-1D7A-4C86-A1E7-BA77906674BF}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{4B875FB3-1D7A-4C86-A1E7-BA77906674BF}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {74BE8749-A1F1-427A-92CF-977EEAC2B413}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>Add_editable_range</RootNamespace>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Syncfusion.DocIO.Net.Core" Version="*" />
11+
</ItemGroup>
12+
13+
<ItemGroup>
14+
<None Update="Output\.gitkeep">
15+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
16+
</None>
17+
</ItemGroup>
18+
19+
</Project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using Syncfusion.DocIO;
2+
using Syncfusion.DocIO.DLS;
3+
using System.IO;
4+
5+
namespace Add_editable_range
6+
{
7+
class Program
8+
{
9+
static void Main(string[] args)
10+
{
11+
//Create a Word document
12+
using (WordDocument document = new WordDocument())
13+
{
14+
//Add a section and a paragraph to the Word document
15+
document.EnsureMinimal();
16+
WParagraph paragraph = document.LastParagraph;
17+
18+
//Append text to the paragraph
19+
paragraph.AppendText("Adventure Works Cycles, the fictitious company on which the AdventureWorks ");
20+
21+
//Add an editable range to the paragraph
22+
EditableRangeStart editableRangeStart = paragraph.AppendEditableRangeStart();
23+
paragraph.AppendText("sample databases are based, is a large, multinational manufacturing company.");
24+
paragraph.AppendEditableRangeEnd(editableRangeStart);
25+
26+
//Set protection with a password to allow read-only access
27+
document.Protect(ProtectionType.AllowOnlyReading, "password");
28+
29+
//Creates file stream
30+
using (FileStream outputStream = new FileStream(Path.GetFullPath(@"Output/Result.docx"), FileMode.Create, FileAccess.ReadWrite))
31+
{
32+
//Saves the Word document to file stream
33+
document.Save(outputStream, FormatType.Docx);
34+
}
35+
}
36+
}
37+
}
38+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.13.35825.156 d17.13
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Find-editable-range-by-id", "Find-editable-range-by-id\Find-editable-range-by-id.csproj", "{003864C5-ADA1-42E9-99FA-B4AC912ACC0F}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{003864C5-ADA1-42E9-99FA-B4AC912ACC0F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{003864C5-ADA1-42E9-99FA-B4AC912ACC0F}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{003864C5-ADA1-42E9-99FA-B4AC912ACC0F}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{003864C5-ADA1-42E9-99FA-B4AC912ACC0F}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {EAADC1D0-BF63-4DF6-B606-1CECD2395ADA}
24+
EndGlobalSection
25+
EndGlobal

0 commit comments

Comments
 (0)