我用c#生成一个excel spread-cheat,我想冻结第一列.这是我使用的代码:
public static void SaveToExcel(object[,] data)
{
Excel = Microsoft.VisualBasic.Interaction.CreateObject("Excel.Application", String.Empty);
Excel.ScreenUpdating = false;
dynamic workbook = Excel.workbooks;
workbook.Add();
dynamic worksheet = Excel.ActiveSheet;
const int left = 1;
const int top = 1;
int height = data.GetLength(0);
int width = data.GetLength(1);
int bottom = top + height - 1;
int right = left + width - 1;
if (height == 0 || width == 0)
return;
dynamic rg = worksheet.Range[worksheet.Cells[top, left], worksheet.Cells[bottom, right]];
rg.Value = data;
// Set borders …Run Code Online (Sandbox Code Playgroud)