Test in a live environment
Test in production without watermarks.
Works wherever you need it to.
Want to keep track of your data and compute averages automatically? Microsoft Excel is the most widely used spreadsheet application in the world, with millions of users. Excel and other spreadsheet programmers are excellent for data manipulation, analysis, and visualization because they allow you to sort, filter, format, and chart your data all in one place. Consider gathering contact information for a field trip.
A table is created by a collection of columns and rows in an Excel spreadsheet. Columns are normally allocated alphabetical letters, while rows are usually assigned numerals. A cell is the intersection of a column and a row. A cell's address is determined by the letter that represents the column and the number that represents the row.
Have you ever wondered how to move columns in Excel tables?
This tutorial covers how to switch or shift multiple columns. Changing adjacent columns is something most people do quite often. This tutorial will show you how to:
When you switch Excel columns with drag and drop, it will only highlight the cells instead of moving them. Use the shift key method if you want to move a selected column; there are a few steps to doing this:
Figure 1 - Microsoft Excel - First Positions
Figure 2 - Microsoft Excel - Second Positions
Figure 3 - Microsoft Excel - Final Position
Note: changing the positions without holding the shift key will overlap the data of the second column.
If the drag and drop method does not work for you, you can also use the cut and paste method. There are the following steps:
Figure 4 - Microsoft Excel - Cut option
Figure 5 - Microsoft Excel - Insert cut cells
Figure 6 - Microsoft Excel - Last Position
Note: You will not be allowed to insert a new column to your chosen area, following a few conditional rules, which are whilst copying/pasting entire columns.
To swap columns in Excel with one move, there are some simple steps:
Figure 7
Figure 8 - Data tab - Select sort
Click on Options.
Figure 9 - Sort Dialog Box - Options
Select the Sort left to right option and Click Ok.
Figure 10 - Sort Options - Sort left to right
Then, in the Sort by option, select row 1 and click OK.
Figure 11 - Sort Dialog Box - Sort by
Delete the newly inserted row.
Result:
Figure 12 - Result
With keyboard shortcut keys, it is easy to switch two columns. Follow these steps to change selected columns:
Figure 13 - Microsoft Excel - First Position
Figure 14 - Microsoft Excel - Second Position
Figure 15 - Microsoft Excel - Final Position
For opening, reading, editing, switching columns, and saving Excel files in .NET, IronXL provides a versatile and powerful framework. It is compatible with all .NET project types, including Windows apps, ASP.NET MVC, and .NET Core Applications.
For .NET developers, IronXL provides a simple API for reading and writing Excel documents.
To access Excel manipulation scripts, IronXL does not require the installation of Microsoft Office Excel on your server, nor the use of Excel Interop. Working with Excel files in .NET becomes incredibly rapid and straightforward due to this.
Using IronXL, developers can perform all Excel related calculations without any complication, simply by writing a few lines of code, including tasks such as adding two cells, total column option, adding an entire column in an Excel table, adding an entire row in an Excel table, all the cells sum function/sum option and sum function of multiple columns and multiple rows, and many other helpful features.
Below are some code examples of the C# code in action.
using IronXL;
WorkBook workbook = WorkBook.Load("test.xlsx");
WorkSheet worksheet = workbook.DefaultWorkSheet;
// Set Formulas
worksheet ["A1"].Formula = "Sum(B8:C12)";
worksheet ["B8"].Formula = "=C9/C11";
worksheet ["G30"].Formula = "Max(C3:C7)";
// Force recalculate all formula values in all sheets.
workbook.EvaluateAll();
// Get Formulas
// Get the formula's calculated value. e.g. "52"
string formulaValue = worksheet ["G30"].Value;
//Get the formula as a string. e.g. "Max(C3:C7)"
string formulaString = worksheet ["G30"].Formula;
//Save your changes with updated formulas and calculated values.
workbook.Save();
using IronXL;
WorkBook workbook = WorkBook.Load("test.xlsx");
WorkSheet worksheet = workbook.DefaultWorkSheet;
// Set Formulas
worksheet ["A1"].Formula = "Sum(B8:C12)";
worksheet ["B8"].Formula = "=C9/C11";
worksheet ["G30"].Formula = "Max(C3:C7)";
// Force recalculate all formula values in all sheets.
workbook.EvaluateAll();
// Get Formulas
// Get the formula's calculated value. e.g. "52"
string formulaValue = worksheet ["G30"].Value;
//Get the formula as a string. e.g. "Max(C3:C7)"
string formulaString = worksheet ["G30"].Formula;
//Save your changes with updated formulas and calculated values.
workbook.Save();
Imports IronXL
Private workbook As WorkBook = WorkBook.Load("test.xlsx")
Private worksheet As WorkSheet = workbook.DefaultWorkSheet
' Set Formulas
Private worksheet ("A1").Formula = "Sum(B8:C12)"
Private worksheet ("B8").Formula = "=C9/C11"
Private worksheet ("G30").Formula = "Max(C3:C7)"
' Force recalculate all formula values in all sheets.
workbook.EvaluateAll()
' Get Formulas
' Get the formula's calculated value. e.g. "52"
Dim formulaValue As String = worksheet ("G30").Value
'Get the formula as a string. e.g. "Max(C3:C7)"
Dim formulaString As String = worksheet ("G30").Formula
'Save your changes with updated formulas and calculated values.
workbook.Save()
Developers have to be careful when they modify and edit Excel files in C# because it can be easy for one misstep to change the whole document. Being able to rely on efficient and straightforward lines of code helps reduce the risk of error and makes it easier for us to edit or delete Excel files programmatically. Today, we'll walk through the steps necessary to edit Excel files in C# quickly and accurately, using functions that have already been well-tested. For more information, please visit the following link.
9 .NET API products for your office documents