The following does work:
namespace ClosedXML_Issues
{
The above generates a value in two cells in sheet2. Perhaps the single quotes around sheet1 is your issue??
namespace ClosedXML_Issues
{
class _443852
{
public void Test()
{
string targetFile = this.ToString() + ".xlsx";
// Create workbook
XLWorkbook wb = new XLWorkbook();
// Sheet1 is just data - as extracted from sql server
IXLWorksheet ws1 = wb.Worksheets.Add("sheet1");
ws1.Cell("A6").Value = 3.14159; // everybody like pi
// On Sheet2 are a number of "='Sheet1'!<CellRef>" formulas (where <CellRef> is the A1 style reference for the cell)
IXLWorksheet ws2 = wb.Worksheets.Add("sheet2");
ws2.Cell("B12").FormulaA1 = @"=sheet1!A6";
// copy the information in sheet2 to a different range on Sheet2
double sourceValue = ws2.Cell("B12").GetDouble();
ws2.Cell("B32").Value = sourceValue;
wb.SaveAs(targetFile);
}
}
}The above generates a value in two cells in sheet2. Perhaps the single quotes around sheet1 is your issue??
- MJH