-
Notifications
You must be signed in to change notification settings - Fork 101
/
devtips.txt
79 lines (64 loc) · 2.81 KB
/
devtips.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
GridWeb .net6 develop guide:
0. add package reference in project file
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.7.0" />
<PackageReference Include="Aspose.Cells.GridWeb" Version="23.10.0" />
1. _viewimport.cs
@using Aspose.Cells.GridWeb
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, Aspose.Cells.GridWeb
2. controller:
put the below code in your desired controller to load gridweb view:
Aspose.Cells.GridWeb.GridWeb.SessionStorePath = @"E:\storage\tmp\gridweb\filecache\";
GridWeb mw = new GridWeb();
mw.ID = "gid";
mw.SetSession(HttpContext.Session);
//set acw_client path
mw.ResourceFilePath = "/js/acw_client/";
//set the picture cache ,you need to create this directory
mw.PictureCachePath = @"E:\storage\tmp\gridweb\piccache";
mw.EnableAsync = true;
//load workbook
String file = Path.Combine(Directory.GetCurrentDirectory(), @"wwwroot\wb\test.xlsx");
mw.ImportExcelFile(file);
//set width height
mw.Width = Unit.Pixel(800);
mw.Height = Unit.Pixel(500);
return View(mw);
3. view
index1.cshtml:
add:
<script src="~/js/acw_client/acwmain.js" asp-append-version="true"></script>
<script src="~/js/acw_client/lang_en.js" asp-append-version="true"></script>
<link href="~/js/acw_client/menu.css" rel="stylesheet" type="text/css">
@model GridWeb
<GridWebDiv mw=Model ></GridWebDiv>
4. add session support and GridScheduedService, (GridScheduedService will delete temporary files two days ago in the GridWeb.SessionStorePath )
startup.cs:
in ConfigureServices method£º
....
services.AddSession(options =>
{
// Set a short timeout for easy testing.
options.IdleTimeout = TimeSpan.FromSeconds(3600);
options.Cookie.HttpOnly = true;
// Make the session cookie essential
options.Cookie.IsEssential = true;
});
services.AddSingleton<Microsoft.Extensions.Hosting.IHostedService, GridScheduedService>();
in Configure method
....
app.UseSession();
5. put latest acw_client in directory: wwwroot/js
6. add acw route map in your controller,which can provide all the operations for general edit action.
check the example in GridController.cs
[HttpGet("acw/{type}/{id}")]
[HttpPost("acw/{type}/{id}")]
public IActionResult Operation(string type, string id)
{
return Aspose.Cells.GridWeb.AcwController.DoAcwAction(this, type, id);
}
7.dependency package references in the demo project:
jquery.js v2.1.1
jquery-ui.js v1.12.1
jquery-ui.css v1.12.1