Giter VIP home page Giter VIP logo

unvell / reogrid Goto Github PK

View Code? Open in Web Editor NEW
1.3K 82.0 383.0 5.52 MB

Fast and powerful .NET spreadsheet component, support data format, freeze, outline, formula calculation, chart, script execution and etc. Compatible with Excel 2007 (.xlsx) format and working on .NET 3.5 (or client profile), WPF and Android platform.

Home Page: https://reogrid.net

License: MIT License

C# 99.61% HTML 0.11% Batchfile 0.28%
dotnet spreadsheet wpf formula calculation grid grid-editor excel excelreader excelwriter

reogrid's People

Contributors

benshi avatar dibargatin avatar dunkhan avatar floele-ww avatar jingwood avatar lamazze avatar lelimacon avatar ottosson avatar rhomgit avatar scorpioqian avatar waizui avatar workgroupengineering avatar ycherkes avatar zhanggaolei001 avatar zxscn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

reogrid's Issues

Sorting ranges

Hello Jing, I have a range

var firstRange = sheet1.Ranges["A5:A24"];

and I want to sort in only firstRange, how can I go about it?

Thank you.

Incorrect display of data in the cell

ReoGrid 2.0 (from reogrid.net). Windows Forms
Visual Studio 2012. Visual Basic
OS: Windows XP, Windows 7, Windows 10

This error occurs rarely

Type of cells is Text.
The text is written in the cells (letters or comma separated numbers). Everything works well.

At a random time after adding data to the cell (programmatically), for example: "2, 6, 8, 12" or "2; 6; 8; 12", a floating-point number is displayed instead of the entered text (for example: "12290.00"). .
If you save data using the usual Save method, the data is saved correctly ("2, 6, 8, 12" or "2; 6; 8; 12").

If you then restart the project, this error disappears - the data in the cell is displayed correctly.

CS1061 'ReoGridControl' does not contain a definition for 'RunScript'

CS1061 'ReoGridControl' does not contain a definition for 'RunScript' and no extension method 'RunScript' accepting a first argument of type 'ReoGridControl' could be found (are you missing a using directive or an assembly reference?) Demo 3 K:\ReoGrid-master\Demo\CellAndRange\MergeCellsDemo.cs

Why it show 32 errors like above when i build in release mode, but no error in debug mode?

Date Sorting Bug

Hi,
I am filling one row with dates from an SQL database. SQL date format is "date" and it is like this in the SQL Server 2016-02-22 but in visual studio it is 22.09.2018. I use this code to format the cells : 22.09.2018

sheet.SetRangeDataFormat("F2:F200", unvell.ReoGrid.DataFormat.CellDataFormatFlag.DateTime, 
    new unvell.ReoGrid.DataFormat.DateTimeDataFormatter.DateTimeFormatArgs
            {

                CultureName = "tr-TR",
                // CultureName = "en-GB",
                Format = "dd.MM.yyyy"
            });

and this code to sort:

sheet.SortColumn(5, "A2:U" + (sipIndex-1).ToString(), unvell.ReoGrid.SortOrder.Ascending);

it doesn't sort by itself i almost try every combination. It only works when i individually click all date cells twice and then press the sort button for sorting. Can you know anything about this problem and how can i solve it?
Thank you for your help in this matter.

Reogrid slow when loading

Hello Jingwood, I have 9 worksheets in reogrid workbook and each sheet has 4120 cells with formulas in them which means 37,080 cells with formulas in the whole workbook.
Whenever I load the program, it takes 32 minutes 25 seconds for the program to come up. Is there a way I can speed up reogrid view when loading because no one will like that kind of program.
Thank you.

Raised exception when sheet resize.

1

I changed the size of the sheet.
Then a "System.ArgumentOutOfRangeException" exception is thrown.

When I redraw the screen in ReoGrid OnPaint, I have a problem.
How should we solve it?

some questions

1.how to set Unprintable Cell?
2.how to set Monochrome printing?
3.A problem with editor, "slash" and "backslash" not work
4.EventArgs.cs line 660, public class RowsHeightChangedEventArgs : WorksheetColumnsEventArgs

Translation

Hello Jing,
Thanks for putting your project on GitHub.
If you need help on translation into French, I can help.

Rank function

Hello Jing, I am trying to implement Excel RANK function using Customize function.

Code:

public static int Rank<T>(T value, IEnumerable<T> data)
{
  return data.OrderByDescending(x => x).ToList().IndexOf(value) + 1;
}

Usage:

int[] data = new[] { 3, 2, 2, 3, 4 };
int rank = Rank(3, data); // returns 2

How do I implement it in Customize function.
Thank you.

Method: worksheet.SetRangeData("A1", dt); Not working..

Hi,

Tried to use worksheet["A1"] = dt; but got this error:
"Number of row is out of the maximum rows, use either AppendRows or Resize to expend this worksheet.
Parameter name: row"

Then tried the method: worksheet.SetRangeData("A1", dt) and only the first data cell from imported spreadsheet was entered in the A1 cell.

My code:

private DataTable GetWorksheetItems()
{
	DataTable d = new DataTable();
	using (ExcelPackage excelPkg = new ExcelPackage())
	{
		using (FileStream stream = new FileStream(ExcelFile.FileName, FileMode.Open, FileAccess.Read))
		{
			excelPkg.Load(stream);
			ExcelWorksheet oSheet = excelPkg.Workbook.Worksheets[DocumentSheet.Name];
			d = WorksheetToDataTable(oSheet);
		}

	}

	return d;
}

// Reading a simple excel sheet that contains only text and numbers into DataTable...
private DataTable WorksheetToDataTable(ExcelWorksheet oSheet)
{
	int totalRows = oSheet.Dimension.End.Row;
	int totalCols = oSheet.Dimension.End.Column;
	DataTable dt = new DataTable(oSheet.Name);
	DataRow dr = null;
	for (int i = 1; i <= totalRows; i++)
	{
		dr = dt.Rows.Add();
		for (int j = 1; j <= totalCols; j++)
		{
			if (i == 1)
			{
				dt.Columns.Add();
				dr[j - 1] = oSheet.Cells[i, j].Value == null ? string.Empty : oSheet.Cells[i, j].Value.ToString();
			}
			else
			{
				dr[j - 1] = oSheet.Cells[i, j].Value == null ? string.Empty : oSheet.Cells[i, j].Value.ToString();

			}
		}
	}
	return dt;
}

public async void OnWorkSheetLoaded(object sender, EventArgs e)
{
	ReoGridControl workSheetsGrid = sender as ReoGridControl;
	Task<DataTable> getWorksheetTask = Task.Factory.StartNew(() => GetWorksheetItems());

	try
	{
		DataTable dt = await getWorksheetTask;
		var sheet = workSheetsGrid.CreateWorksheet(DocumentSheet.Name);
		sheet.SetRangeData("A1", dt);
		workSheetsGrid.AddWorksheet(sheet);
	}
	catch (Exception x)
	{
		throw new ArgumentNullException(x.Message);
	}
}

I'm using EPPlus to read an xlxs to the DataTable, it works fine with Xceed Grid and ExtendedDataGrid, but no success here. Is there something I'm doing wrong?

EndEdit after pressing left or right keys

Hi,

I've implemented behavior when pressing left or right when editing a cell for WinForms.
I wanted to implement it for WPF and Android as well, but I couldn't get it compiling. I did change project settings for #WPF, but I seems there's more to it.
I'm also not really familiar with Git. I'm a mercurial user and not really active in online repos. So I had a bit of trouble attempting to get this code to you. So instead posting it below in the issue.

If you're interested in adding this change; replacing the OnKeyDown method of the InputTextBox in the WinForms control of Reogrid with the code below should do the trick. I guess it's peanuts for you to implement the same behavior in WPF and android as well.

I also want to point out that default Excel behavior when pressing "ENTER" while editing a cell will move the selection to the cell below. In your behavior you move to the right. Of course I don't know how literally you want to mimic Excel with these kind of behaviors?

Thanks!

           protected override void OnKeyDown(KeyEventArgs e)
            {
                var sheet = owner.currentWorksheet;

                if (sheet.currentEditingCell != null && Visible)
                {
                    bool isProcessed = false;

                    // in single line text
                    if (!TextWrap && Text.IndexOf('\n') == -1)
                    {
                        isProcessed = true;
                        if (e.KeyCode == Keys.Up)
                        {
                            ProcessSelectionMoveKey(e, sheet, () => sheet.MoveSelectionUp());
                        }
                        else if (e.KeyCode == Keys.Down)
                        {
                            ProcessSelectionMoveKey(e, sheet, () => sheet.MoveSelectionDown());
                        }
                        else if (e.KeyCode == Keys.Left && SelectionStart == 0)
                        {
                            ProcessSelectionMoveKey(e, sheet, () => sheet.MoveSelectionLeft());
                        }
                        else if (e.KeyCode == Keys.Right && SelectionStart == Text.Length)
                        {
                            ProcessSelectionMoveKey(e, sheet, () => sheet.MoveSelectionRight());
                        }
                        else
                        {
                            isProcessed = false;
                        }
                    }

                    if (!isProcessed)
                    {
                        if (!Toolkit.IsKeyDown(Win32.VKey.VK_CONTROL) && e.KeyCode == Keys.Enter)
                        {
                            ProcessSelectionMoveKey(e, sheet, () => sheet.MoveSelectionRight());
                        }
                    }
                }
            }

            private void ProcessSelectionMoveKey(KeyEventArgs e, Worksheet sheet, Action moveAction)
            {
                e.SuppressKeyPress = true;
                sheet.EndEdit(Text);
                moveAction();
            }

The CategoryNameRange only supported by pass a row data not a column data?

In the code below I find that the code to get CategoryName increated by column index
So if I pass a column data to CategoryNameRange then it works not what i want.

		/// <summary>
		/// Get or set the range that contains the category names.
		/// </summary>
		public RangePosition CategoryNameRange { get; set; }
	/// <summary>
	/// Return the title of specified column.
	/// </summary>
	/// <param name="index">Zero-based number of column.</param>
	/// <returns>Return the title that will be displayed on chart.</returns>
	public string GetCategoryName(int index)
	{
		if (this.CategoryNameRange.IsEmpty)
		{
			return null;
		}
		else
		{
			return this.worksheet.GetCellData<string>(this.CategoryNameRange.Row, this.CategoryNameRange.Col + index);
		}
	}

WPF Blank SpreadSheet returning: System.ArgumentNullException

Hello,

I'm creating a WPF application using your spreadsheet. I started a simple empty spreadsheet using the code in my xaml:

<rg:ReoGridControl x:Name="grid">
                </rg:ReoGridControl>

However, every time I try to input any information in the empty cells like a user would do, the application crashes returning the erro: System.ArgumentNullException.

What is even more odd, it's if a put a simple "hello world" in the first cell the entire spreadsheet start to accept inputs without crashing.

Sorry if this a dumb question. I'm very new to wpf and using Reogrid.

Reference local variable in another method

Hello Jingwood, I have method_1 with Reogrid control, workbook and worksheets created, I want the code for the calculations in a method_2 so I can call method_2 from method_1. I have tried making the methods public void but it is giving me error. How do you suggest I go about it?
Thank you

Copy/Paste on readonly cell will overwrite content

Hi,

Copying one cell, and pasting it on a readonly cell will write the data regardless.

I expect a readonly cell to be really readonly. For such I already provided you with a pull request regarding autofillserial, that also had this problem. And now create this issue reagrding copy/pasting. This copy/pasting logic goes quite a bit deeper in the solution and touches quite a lot of aspects of ReoGrid. So I don't feel confident doing this change without diving a lot deeper into Reogrid. I hope you can help here.

Regards,
Koen

Not able to read excel cell data

Hi,

I came across this issue when I was trying to Load an excel file exported from SSRS. The issue in question was because the the Cell class does not support the structure that my file has. The structure is as follows.

Exchange

So the ElementText value is always null and nothing comes up on the UI.

InvalidOperationException when saving a Memory Workbook

We currently use ReoGridWPF to export some data to an xlsx-file and not as an actual WPF component. When Saving a MemoryWorkbook from a thread that is not the thread owning the MainWindow, we get an InvalidOperationException that says 'The calling thread cannot access this object because a different thread owns it'. This comes from the fact that during the call to the Save function of the IWorkbook, the following code is executed (in a function called PlatformUtility.GetDPI()):

PresentationSource source = PresentationSource.FromVisual(Application.Current.MainWindow);

Hence, as current thread does not own the MainWindow, the exception is thrown. This behavior does not really make sense for a Memory Workbook as the code using the workbook does not necessarily include a MainWindow. In our case, we can work around this error by calling the Save-functionality a first time from the main tread with a dummy export name in order to get a DPI that is then re-used in the GetDPI-function, avoiding calling the line throwing the exception above. But it doesn't really feel like a nice solution. My belief is that the Memory Workbook should not be dependent on having a MainWindow at all.

WorksheetRangeStyle Question.

I created a WorksheetRangeStyle to set style an range of cells, this work fine over the control but at the moment in which export the content to excel format (.xlsx) this style is ignored.

Code:

sheet.SetRangeStyles(range, new WorksheetRangeStyle
{
          Flag = PlainStyleFlag.All,
          Italic = false,
          Bold = true,
          Underline = false,
          FontSize = 10,
          TextWrapMode = TextWrapMode.NoWrap,
          HAlign = ReoGridHorAlign.Left,
          VAlign = ReoGridVerAlign.Middle,
          TextColor = SolidColor.Black,
          BackColor = SolidColor.Transparent
});

On Save() method I send FileFormat.Excel2007 as second parameter.

Read Excel Formula Mistake

Hi,
I have written a little code in VB NET to read the cells data from an excel file where there is some formulas. However, the read result is different from the value that is in the original excel sheet and I don't know why.
In the column O2 to O7 of the excel file the value is "Case01", Case04", "Case03", "Case07", Case08" but the values that the program read are: "Case01","Case04","Case08","Case08","Case08". (I attach the screen image of the excel file and the program, the code in a txt file and the excel file).
Could you help me to discover where is my mistake?
Thank you

Form1.vb.txt

Data01.xlsx
imagen

imagen

Cell that hold Custom Data Type

Hi,
I'm new to ReoGrid. I want to know if Cell can store custom Data Type because I see that all the data is convert into string?
Forexample, I have a class call "ImageData" and I want a cell to store this data, then when I pass that Cell to another function, I can access ImageData (not the string value).

Update: I can make the cell to store a custom Data Type now by modified the source code. I create a new FormulaValueType named Object then in the CreateFormulaValue(object obj) method, instead of convert object to string, I return a new FormulaValue with FormulaValueType.Object and the value = object.
Then finally I can use the Cell data (not the string) when using CustomFunctions.
Thanks

Using Worksheet with each cell

Hello, I have 3 worksheets (gold, silver, copper) and I am setting the same formula "=SUM(C3:D3)" for the same cell F2. Instead of writing:

gold["F2"] = "=SUM(C3:D3)";
sliver["F2"] = "=SUM(C3:D3)";
copper["F2"] = "=SUM(C3:D3)";

Is it not possible to write:

object[] workbook = { gold["F2"], silver["F2"], copper["F2"] };

string formula = "=SUM(C3:D3)";

foreach (object sheet in workbook )
{
sheet = formula;
}

I have tried using this and for() but it is not working or am I missing a cast?
Thank you

The content of a range cannot be clear completely?

Here is the code I wrote to append a new column and fill it will button, **it won't work in the second time I call it. It will throw a System.NullReferenceException Exception. **

this.DefaultWorksheet.AppendCols(1);
NewCol = this.DefaultWorksheet.MaxContentCol + 1;
this.DefaultWorksheet.ColumnHeaders[NewCol].Text = HeaderName; // this line will cause a exception in the second time. 
// set header.text of the new col
// add buttons to the cells of this new column

I will give as much as details as I can.
the call track is:

  1. QueryButtonClick(): Fill a DataTable
  2. Fill():
  • use SetRows and SetCols to resize the worksheet to match the the size of the DataTable
  • then I clear the whole(use ColumnCount and RowCount to generate a range) worksheet by ClearRangeContent() passing the flag CellElementFlag.All. It work just find when I test it, it will clear all the data inside the worksheet. I don't clear the header.text of all column in here.
  • use worksheet["A1"] = DataTable to fill the worksheet
  1. set filter to all columns
  2. AppendButtonColumn(), as the code you can see above, it will append a new column in worksheet, I assume the new column shoule be empty(I clear the whole sheet and resize it to match the size of my DataTable), so it won't be counted into the MaxContentCol, so the index of the new column will be NewCol = MaxContentCol + 1; then I set this new column's text, and add button to every cell of this column. The first time I click the QueryButton, it can work. But the second time I got a System.NullReferenceException exception.
    I debug it and watch the change of three concerned variable: the ColumnCount, MaxContentCount and the NewCol. It will change like this:
  • The first time:
Variable Name At beginning Call AppendCols NewCol = MaxContentCol + 1
ColumnCount 17 18 18
MaxContentCol 16 16 16
NewCol 0 0 17
  • The second time:
Variable Name At beginning Call AppendCols NewCol = MaxContentCol + 1
ColumnCount 17 18 ERROR
MaxContentCol 16 17 ERROR
NewCol 0 0 ERROR

** When I call AppendCols(1) the second time, ColumnCount and MaxContentCount both increase one.
Is there something I did wrong?
Maybe it is because I didn't delete the header.text, so it will regard the new line as been used? If so, then SetRows and SetCols Method will reserved the old data so it actully is the method to determind how many rows and cols can be see? **

Right now already replace the AppendCol code with the Resize. It works.

NewCol = this.DefaultWorksheet.MaxContentCol + 1;
this.DefaultWorksheet.Resize(this.DefaultWorksheet.MaxContentRow + 1, NewCol + 1);

Mistake reading symbols

Hi Jing,
I have found a small mistake reading an excel file. I don't understand why it can´t read the file Test1.xlsx. This file has a cell with a symbol character together with other normal characters. In the file Test2.xlsx. I have removed the space between the two types and then, it works. I suppose there is something wrong.
I have this problem with the version 2.0 and not with 0.9.3
Regards,
Navasender

P.D. I attach a .rar file with the example of the mistake.
ExcelReadMistakeII.zip

Method for trimming empty rows?

Hi Jing,

Other than me programmatically skipping empty rows during import, do you have a method for trimming empty rows after the last valid data row?

Problem on formula

I have a sheet in which
A1 = nnnn & B1
A2 = nnnn & B2
...
An = nnnn & Bn
where nnnn is a 4-digit number and cells B1-Bn are strings with always three-digit numbers with possible initial zeros such as
001, 002, ..., 020, ..., 120

The result in the Ax cells is a string for example
nnnn001
nnnn002
nnnn020
nnnn120

Loading on reogrid
Bx cells are loaded as strings, Ax cells are loaded as double.
The end result is always the nnnn string as if there was no "& Bx"

If I modify the formula of the cells Ax from <nnnn & Bx> to <"nnnn" & Bx> works and Ax cells have the correct value.

Unfortunately, the input file can not be edited because it is produced by an external entity.

Is there another way to get the final result?

Thank you

GetDefaultDataSerialFillColor error when the index==defaultDataSerialColors.Count

The GetDefaultDataSerialFillColor function in ReoGrid\Chart\Utility.cs will cause exception when the parameter index==defaultDataSerialColors.Count

Below is the code of the GetDefaultDataSerialFillColor function:

     public static SolidColor GetDefaultDataSerialFillColor(int index)
	{
		if (defaultDataSerialColors == null)
		{
			defaultDataSerialColors = new List<SolidColor>()
			{
				new SolidColor(91,155,213),
				new SolidColor(237,125,49),
				new SolidColor(165, 165, 165),
				new SolidColor(255,192,0),
				new SolidColor(22,191,177),
				new SolidColor(165,196,86),
				new SolidColor(69,35,163),
				new SolidColor(212,98,117),
				new SolidColor(241,131,151),
				new SolidColor(208,199,6),
				new SolidColor(255,50,50),
			};
		}

		if (index >= defaultDataSerialColors.Count)
		{
			if (index < MaxDataSerials)
			{
				for (int i = defaultDataSerialColors.Count; i < index; i++)
				{
					defaultDataSerialColors.Add(SolidColor.Randomly());
				}
			}
			else
			{
				index = index % MaxDataSerials;
			}
		}

		return defaultDataSerialColors[index];
	}
	#endregion // Shared Row Colors

The loop for (int i = defaultDataSerialColors.Count; i < index; i++) should change to for (int i = defaultDataSerialColors.Count; i <= index; i++) .

跨表公式计算问题

Formula:
=SUM(Sheet2!A1:A10) Why couldn't calculated the result
上面的公式为什么不能计算出结果? 计算结果为0
但是如果我在公式单元格所在的Sheet表的A1-A10的单元格填值,则会求和,也就是不支持跨表公式计算么? 但是我在调试源码的时候,发现公式是解析出了Sheet2表的, 这是不是BUG?

Request: Freeze rows/columns on every page when printing

It would be nice to be able to tell the printsession that frozen rows and columns should be added to every printed page.
I would consider implementing this myself but it would be good if someone can give me a basic description of how this could best be integrated with the current framework. I do not want to just start experimenting.

Is there anyone help translating the Document to Chinese?

Hi, I couldn't find a contact in the website, So I post a "issue" in here.
ReoGrid is awesome, but I find out there is no Chinese document in the website(only Japanese, Russian), I wonder is there anyone help translating the Chinese version of the document?
If there isn't, may I help translating?
I had help translating some articles for other translting project, and I hope ReoGrid will be more popular in China, if we have a Chinese version.
Thanks.

Formula bar

I inserted reogrid in my wpf project.
I visualize worksheets but without the formula bar
How can I do ?
Thanks a lot

Lowercase characters

It's possible write a formula using lowercase characters ("a1 + b1" instead of "A1 + B1") ?
Thank you

Releases

Hello Jing,
It would be a great idea to add samples on Releases Tab.

DemoWPF not working

DemoWPF not working. In MainWindow.xaml.cs, InitializeComponent() not found, all 'grid' not found.

Default Row Height & Column header

Hi
it would be nice to have default row height (in ReoGrid style(code) or in properties in UI component)
currently we have to iterate throughout every row manually and set height of row.

i'm not sure if we can set the following in current release

  • Column header height
  • Column header color

Best Regards,
Prakash

FreezePanes

Reogrid support FreezePanes ?
If yes how can I do to use this function ?
Many thanks

Export to Excel. Broken Excel files

ReoGrid 2.0 (from reogrid.net). Windows Forms. Standard
IDE: Visual Studio 2012. Visual Basic
OS: WIndows 10

Brief:
After Export to Excel do not work standard option "Format Cell" and problem with backgrounds

Full:
Actions:

  1. Creating a empty rgf file
    1

  2. Resizing (12 cols, approx. 100 rows), formatting and adding a background for multiple ranges of cells
    2

  3. Adding data (text only)
    3

  4. Saving with standard method Save

  5. Exporting to Excel

  6. Opening with Excel 2010

  7. Do not work option "Format Cell" (Excel's window does not appear) and problems with backgrounds
    Area with data have white background - OK
    Areas outside the data range have an alternate color, which was previously specified only for the data area.
    4

Code (Styling, Exporting - fragments)

Set styles

intMaxCols = ws.ColumnCount - 1
intmaxRows = ws.RowCount - 1

Dim StartStyle As New WorksheetRangeStyle
StartStyle.Flag = PlainStyleFlag.FontName Or PlainStyleFlag.FontSize Or PlainStyleFlag.AlignAll Or PlainStyleFlag.Padding Or PlainStyleFlag.TextWrap
StartStyle.FontName = xxx.strFontName
StartStyle.FontSize = CSng(Val(xxx.intCells)) 'CSng(Val(xxx.intCells))
StartStyle.HAlign = ReoGridHorAlign.Center
StartStyle.VAlign = ReoGridVerAlign.Middle
StartStyle.TextWrapMode = TextWrapMode.WordBreak

Dim DayStyleFont As New WorksheetRangeStyle
With DayStyleFont
    .Flag = PlainStyleFlag.FontName Or PlainStyleFlag.FontSize Or PlainStyleFlag.AlignAll Or PlainStyleFlag.RotateAngle Or PlainStyleFlag.TextWrap
    .FontName = xxx.strFontName
    .FontSize = CSng(Val(xxx.int10Days))
    .HAlign = ReoGridHorAlign.Center
    .VAlign = ReoGridVerAlign.Middle
    .RotateAngle = 90
    .TextWrapMode = TextWrapMode.WordBreak
End With

Dim MainStyle As New WorksheetRangeStyle
MainStyle.Flag = PlainStyleFlag.BackColor
MainStyle.BackColor = Color.Empty

Dim AlterStyle As New WorksheetRangeStyle
AlterStyle.Flag = PlainStyleFlag.BackColor
AlterStyle.BackColor = Color.FromArgb(255, 173, 216, 230)

Dim stlBold As New RangeBorderStyle
Dim stlSolid As New RangeBorderStyle
Dim stlDashed As New RangeBorderStyle

'Line type
stlBold.Style = BorderLineStyle.BoldSolid 'Полужирная сплошная
stlBold.Color = Color.Black
stlDashed.Style = BorderLineStyle.Dashed 'Штриховая
stlDashed.Color = Color.Black
stlSolid.Style = BorderLineStyle.Solid 'Сплошная
stlSolid.Color = Color.Black

'Start style
.SetRangeStyles(0, 0, intmaxRows, intMaxCols, StartStyle)

Dim intK1 As Integer = 1
For intI As Integer = intHeaderRowNum + 1 To intmaxRows - 8 Step 7
	.SetRangeStyles(intI, 0, 1, 1, DayStyleFont)

	If (intK1 Mod 2 = 0) Then
		ws.SetRangeStyles(intI, 0, 7, ws.ColumnCount, AlterStyle)
	Else
		ws.SetRangeStyles(intI, 0, 7, ws.ColumnCount, MainStyle)
	End If

	intK1 += 1
Next

.Cells("A1").Style.FontSize = 16

'Ranges
ws.SetRangeBorders(intHeaderRowNum + 1, 0, intmaxRows - (intHeaderRowNum + 2), ws.ColumnCount, BorderPositions.InsideAll, stlSolid)
ws.SetRangeBorders(intHeaderRowNum + 1, 0, intmaxRows - (intHeaderRowNum + 2), ws.ColumnCount, BorderPositions.Outside, stlSolid)

For intI As Integer = intHeaderRowNum To intmaxRows - 2 Step 7
	ws.SetRangeBorders(intI, 0, 1, ws.ColumnCount, BorderPositions.Bottom, stlBold)
Next
End With

For intX As Integer = 0 To intmaxRows
	ws.AutoFitRowHeight(intX)
Next

For intX2 As Integer = 0 To intMaxCols
	ws.AutoFitColumnWidth(intX2)
Next

Export to Excel

Dim frmXXX As New Form
Dim rGridX As New ReoGridControl

With rGridX
'Init
.CurrentWorksheet.SelectionStyle = WorksheetSelectionStyle.Default
.CurrentWorksheet.SelectionMode = WorksheetSelectionMode.Range
.CurrentWorksheet.SelectionForwardDirection = unvell.ReoGrid.SelectionForwardDirection.Down
.CurrentWorksheet.SetSettings(WorksheetSettings.View_ShowGridLine, True)
.CurrentWorksheet.SetSettings(WorksheetSettings.View_ShowPageBreaks, True)
.CurrentWorksheet.SetSettings(WorksheetSettings.View_ShowRowHeader, True)
.CurrentWorksheet.SetSettings(WorksheetSettings.View_ShowColumnHeader, True)
.CurrentWorksheet.SetSettings(WorksheetSettings.View_AllowShowRowOutlines, True)
.CurrentWorksheet.SetSettings(WorksheetSettings.View_AllowShowColumnOutlines, True)
.CurrentWorksheet.SelectionMode = WorksheetSelectionMode.Cell

.SetSettings(WorkbookSettings.View_ShowSheetTabControl, False)
.SetSettings(WorkbookSettings.View_ShowScrolls, True)
.SetSettings(WorkbookSettings.View_ShowHorScroll, True)
.SetSettings(WorkbookSettings.View_ShowVerScroll, True)

.Load(strFileNameR, unvell.ReoGrid.IO.FileFormat.ReoGridFormat, Encoding.UTF8)
frmXXX.Controls.Add(rGridX)

.CurrentWorksheet.ShowRows(0, intHeaderRowNum)
.CurrentWorksheet.Unfreeze()

Dim strX As String = String.Empty

'Autocorrection (fragment)
For intI As Integer = 0 To .CurrentWorksheet.RowCount - 1
	For intJ As Integer = 0 To .CurrentWorksheet.ColumnCount - 1
		strX = .CurrentWorksheet.Cells(intI, intJ).DisplayText

'Other code for strings

           'Change background for data areas
		.CurrentWorksheet.Cells(intI, intJ).Style.BackColor = Color.White
	Next intJ
Next intI

'Saving
Dim strFileName As String = "xxx.xlsx"
.Save(strFileName, unvell.ReoGrid.IO.FileFormat.Excel2007)
frmXXX.Close()
End With

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.